OpenAPI 1.0

com.aquafold.openapi.rdbms
Interface AQServerConnection


public interface AQServerConnection

This interface represents a database server connection.


Method Summary
 void changeDatabase(String name)
          Change database in the current connection.
 void changeSchema(String name)
          Change schema in the current connection.
 void commit()
          Commits a transaction.
 void connect()
          Establish SQL connection to the server.
 void connect(Object password)
          Establish SQL connection to the server with the provided password.
 void connect(Object username, Object password)
          Establish SQL connection to the server with the provided user credentials.
 void disconnect()
          Disconnect a server connection.
 boolean execute(String sql)
          Execute a query.
 AQResultSet executeQuery(String sql)
          Execute a query to get a result set.
 AQScriptResult executeScript(String script)
          Executes a script, which may contain multiple statements, and may produce multiple result sets.
 AQDataSet executeSnapshot(String sql)
          Execute query and extract data into AQDataSet.
 int executeUpdate(String sql)
          Execute an update query.
 String getCurrentDatabase()
          Get the current database the connection is connected to.
 Connection getJdbcConnection()
          Returns underlying JDBC connection.
 AQMetadata getMetadata()
          Get metadata object which allows for introspection of the database structure.
 String getName()
          Get connection name (as seen in the schema tree).
 AQScriptOptions getScriptOptions()
          Returns an instance of AQScriptOption object associated with the given connection.
 String getSessionID()
          To get the connection session id.
 String getVersionString()
          Get database/server version.
 boolean isCaseSensitive()
          Returns true if names in this connections are case sensitive.
 boolean isConnected()
          Get the connection status of the connection session.
 AQScriptOptions newScriptOptions()
          Creates a copy of AQScriptOption object associated with the given connection.
 AQScriptParser newScriptParser()
          Creates a new script parser object.
 AQSqlFormatter newSqlFormat()
          Creates new SQL formatter object.
 void rollback()
          Rolls back a transaction.
 void setAutoCommit(boolean enable)
          Sets auto-commit mode.
 String sqlEncode(String string)
          Escapes single quote characters in a string to make it safe for inclusion into a SQL query.
 

Method Detail

getName

String getName()
Get connection name (as seen in the schema tree).

Returns:
The name of the connection.

getSessionID

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(String sql)
                throws Exception
Execute a query.

Parameters:
sql - The SQL statement.
Returns:
true : If the first result is a ResultSet object;
false: If it is an update count or there are no results.
Throws:
Exception - on error. eg. if SQL statement

executeUpdate

int executeUpdate(String sql)
                  throws Exception
Execute 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:
Exception - If SQL statement is not a data manipulation statement.

executeQuery

AQResultSet executeQuery(String sql)
                         throws Exception
Execute a query to get a result set.

Parameters:
sql - The SQL statement.
Returns:
An AQResultSet object.
Throws:
Exception - If SQL statement is a data manipulation statement.

executeSnapshot

AQDataSet executeSnapshot(String sql)
                          throws 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:
Exception - on error.

connect

void connect()
             throws Exception
Establish SQL connection to the server.

Throws:
Exception - on error.

connect

void connect(Object password)
             throws Exception
Establish SQL connection to the server with the provided password.

Parameters:
password - A String password or a AQOpaqueObject with the password.
Throws:
Exception - on error.

connect

void connect(Object username,
             Object password)
             throws Exception
Establish SQL connection to the server with the provided user credentials.

Parameters:
username - A String or a AQOpaqueObject with the user name.
password - A String password or a AQOpaqueObject with the password.
Throws:
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

String getVersionString()
Get database/server version.

Returns:
The database version string.

isCaseSensitive

boolean isCaseSensitive()
Returns true if names in this connections are case sensitive.


changeDatabase

void changeDatabase(String name)
                    throws Exception
Change 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:
Exception

changeSchema

void changeSchema(String name)
                  throws Exception
Change schema in the current connection. This method only supports databases that support schemas.

Parameters:
name - The name of the schema.
Throws:
Exception

executeScript

AQScriptResult executeScript(String script)
                             throws Exception
Executes a script, which may contain multiple statements, and may produce multiple result sets.

Parameters:
script - The script to be executed.
Throws:
Exception

sqlEncode

String sqlEncode(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.


newSqlFormat

AQSqlFormatter newSqlFormat()
Creates new SQL formatter object.


newScriptParser

AQScriptParser newScriptParser()
Creates a new script parser object.

Returns:
AQScriptParser

getCurrentDatabase

String getCurrentDatabase()
Get the current database the connection is connected to.

Returns:
The database name.

getJdbcConnection

Connection getJdbcConnection()
Returns underlying JDBC connection.

Returns:
an instance of Connection

setAutoCommit

void setAutoCommit(boolean enable)
                   throws Exception
Sets auto-commit mode. This method is equivalent of Connection.setAutoCommit(boolean).

Throws:
Exception

rollback

void rollback()
              throws Exception
Rolls back a transaction. This method is equivalent of Connection.rollback().

Throws:
Exception

commit

void commit()
            throws Exception
Commits a transaction. This method is equivalent of Connection.commit().

Throws:
Exception

OpenAPI 1.0


Copyright © 2010 AquaFold, Inc. All Rights Reserved. Use is subject to license terms.