Package com.aquafold.openapi.rdbms
Interface AQServerConnection
-
public interface AQServerConnectionThis interface represents a database server connection.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidchangeDatabase(java.lang.String name)Change database in the current connection.voidchangeSchema(java.lang.String name)Change schema in the current connection.voidcommit()Commits a transaction.voidconnect()Establish SQL connection to the server.voidconnect(java.lang.Object password)Establish SQL connection to the server with the provided password.voidconnect(java.lang.Object username, java.lang.Object password)Establish SQL connection to the server with the provided user credentials.voiddisconnect()Disconnect a server connection.booleanexecute(java.lang.String sql)Execute a query.AQResultSetexecuteQuery(java.lang.String sql)Execute a query to get a result set.AQScriptResultexecuteScript(java.lang.String script)Executes a script, which may contain multiple statements, and may produce multiple result sets.AQDataSetexecuteSnapshot(java.lang.String sql)Execute query and extract data into AQDataSet.intexecuteUpdate(java.lang.String sql)Execute an update query.java.lang.StringgetCurrentDatabase()Get the current database the connection is connected to.java.sql.ConnectiongetJdbcConnection()Returns underlying JDBC connection.AQMetadatagetMetadata()Get metadata object which allows for introspection of the database structure.java.lang.StringgetName()Get connection name (as seen in the schema tree).AQScriptOptionsgetScriptOptions()Returns an instance of AQScriptOption object associated with the given connection.java.lang.StringgetSessionID()To get the connection session id.java.lang.StringgetVersionString()Get database/server version.booleanisCaseSensitive()Returns true if names in this connections are case sensitive.booleanisConnected()Get the connection status of the connection session.AQScriptOptionsnewScriptOptions()Creates a copy of AQScriptOption object associated with the given connection.AQScriptParsernewScriptParser()Creates a new script parser object.AQSqlFormatternewSqlFormat()Creates new SQL formatter object.voidrollback()Rolls back a transaction.voidsetAutoCommit(boolean enable)Sets auto-commit mode.java.lang.StringsqlEncode(java.lang.String string)Escapes single quote characters in a string to make it safe for inclusion into a SQL query.
-
-
-
Method Detail
-
getName
java.lang.String getName()
Get connection name (as seen in the schema tree).- Returns:
- The name of the connection.
-
getSessionID
java.lang.String getSessionID()
To get the connection session id.- Returns:
- The session id, as a string, if available; empty string if it is not available.
-
getMetadata
AQMetadata getMetadata()
Get metadata object which allows for introspection of the database structure.- Returns:
- An AQMetaData object;
-
execute
boolean execute(java.lang.String sql) throws java.lang.ExceptionExecute a query.- Parameters:
sql- The SQL statement.- Returns:
true: If the first result is aResultSetobject;
false: If it is an update count or there are no results.- Throws:
java.lang.Exception- on error. eg. if SQL statement
-
executeUpdate
int executeUpdate(java.lang.String sql) throws java.lang.ExceptionExecute an update query.- Parameters:
sql- The SQL statement.- Returns:
- An integer value of either
1. the row count for SQL Data Manipulation Language (DML) statements
2. 0 for SQL statements that return nothing. - Throws:
java.lang.Exception- If SQL statement is not a data manipulation statement.
-
executeQuery
AQResultSet executeQuery(java.lang.String sql) throws java.lang.Exception
Execute a query to get a result set.- Parameters:
sql- The SQL statement.- Returns:
- An AQResultSet object.
- Throws:
java.lang.Exception- If SQL statement is a data manipulation statement.
-
executeSnapshot
AQDataSet executeSnapshot(java.lang.String sql) throws java.lang.Exception
Execute query and extract data into AQDataSet. Since the data will be cached in memory, the size of data set may be limited by available memory.- Parameters:
sql- The SQL statement.- Returns:
- An AQDataSet object.
- Throws:
java.lang.Exception- on error.
-
connect
void connect() throws java.lang.ExceptionEstablish SQL connection to the server.- Throws:
java.lang.Exception- on error.
-
connect
void connect(java.lang.Object password) throws java.lang.ExceptionEstablish SQL connection to the server with the provided password.- Parameters:
password- AStringpassword or aAQOpaqueObjectwith the password.- Throws:
java.lang.Exception- on error.
-
connect
void connect(java.lang.Object username, java.lang.Object password) throws java.lang.ExceptionEstablish SQL connection to the server with the provided user credentials.- Parameters:
username- AStringor aAQOpaqueObjectwith the user name.password- AStringpassword or aAQOpaqueObjectwith the password.- Throws:
java.lang.Exception- on error.
-
isConnected
boolean isConnected()
Get the connection status of the connection session.- Returns:
- true - If server is valid or has not been closed
false - If connection is not valid or has been closed.
-
disconnect
void disconnect()
Disconnect a server connection.
-
getVersionString
java.lang.String getVersionString()
Get database/server version.- Returns:
- The database version string.
-
isCaseSensitive
boolean isCaseSensitive()
Returns true if names in this connections are case sensitive.- Returns:
- TRUE if it is case sensitive
-
changeDatabase
void changeDatabase(java.lang.String name) throws java.lang.ExceptionChange database in the current connection. This method only supports databases that support multiple database connections per connection.- Parameters:
name- The name of the database.- Throws:
java.lang.Exception- On error
-
changeSchema
void changeSchema(java.lang.String name) throws java.lang.ExceptionChange schema in the current connection. This method only supports databases that support schemas.- Parameters:
name- The name of the schema.- Throws:
java.lang.Exception- On error
-
executeScript
AQScriptResult executeScript(java.lang.String script) throws java.lang.Exception
Executes a script, which may contain multiple statements, and may produce multiple result sets.- Parameters:
script- The script to be executed.- Returns:
- the script result
- Throws:
java.lang.Exception- On error
-
sqlEncode
java.lang.String sqlEncode(java.lang.String string)
Escapes single quote characters in a string to make it safe for inclusion into a SQL query. Depending on the database, the backslash characters will also be escaped.- Parameters:
string- The string to be encoded.- Returns:
- The encoded string.
-
getScriptOptions
AQScriptOptions getScriptOptions()
Returns an instance of AQScriptOption object associated with the given connection. This allows the user to set user optional quote identifiers, line separators, statement separators, etc.- Returns:
- An AQScriptOptions object in use in this specific connection.
-
newScriptOptions
AQScriptOptions newScriptOptions()
Creates a copy of AQScriptOption object associated with the given connection. Any changes made to this instance do not affect options associated with the given connection.- Returns:
- the script options
-
newSqlFormat
AQSqlFormatter newSqlFormat()
Creates new SQL formatter object.- Returns:
- the SQL formmatter
-
newScriptParser
AQScriptParser newScriptParser()
Creates a new script parser object.- Returns:
- AQScriptParser
-
getCurrentDatabase
java.lang.String getCurrentDatabase()
Get the current database the connection is connected to.- Returns:
- The database name.
-
getJdbcConnection
java.sql.Connection getJdbcConnection()
Returns underlying JDBC connection.- Returns:
- an instance of
Connection
-
setAutoCommit
void setAutoCommit(boolean enable) throws java.lang.ExceptionSets auto-commit mode. This method is equivalent ofConnection.setAutoCommit(boolean).- Parameters:
enable- to enable/disable- Throws:
java.lang.Exception- On error
-
rollback
void rollback() throws java.lang.ExceptionRolls back a transaction. This method is equivalent ofConnection.rollback().- Throws:
java.lang.Exception- On error
-
commit
void commit() throws java.lang.ExceptionCommits a transaction. This method is equivalent ofConnection.commit().- Throws:
java.lang.Exception- On error
-
-