org.objectweb.cjdbc.driver
Class Connection

java.lang.Object
  extended byorg.objectweb.cjdbc.driver.Connection
All Implemented Interfaces:
java.sql.Connection

public class Connection
extends java.lang.Object
implements java.sql.Connection

This class implements the communication protocol to the Controller.

Connection.java was inspired from the PostgreSQL JDBC driver by Peter T. Mount.

Version:
2.0
Author:
Emmanuel Cecchet , Julie Marguerite , Vadim Kassin , Duncan Smith , Nicolas Modrzyk , Jaco Swart , Marc Herbert , Jean-Bernard van Zuylen

Field Summary
protected  boolean autoCommit
          Commit mode of the connection (true= automatic).
private  AbstractBlobFilter blobFilter
           
private  CjdbcUrl cjdbcUrl
          Parsed URL to the database.
private  boolean closeSocketOnGC
           
private  boolean connectionPooling
           
protected  ControllerInfo controllerInfo
          C-JDBC controller we are connected to
protected  boolean controllerNeedsSqlSkeleton
          Does the controller wants SQL templates of PreparedStatements?
static int DEFAULT_TRANSACTION_ISOLATION_LEVEL
          Default transaction isolation level if the user has not enforced one
protected  Driver driver
          Driver that created us.
protected  boolean driverProcessed
           
protected  boolean escapeBackslash
           
protected  java.lang.String escapeChar
           
protected  boolean escapeSingleQuote
           
protected  java.sql.SQLWarning firstWarning
          List of Warnings for this connection.
protected  boolean isClosed
          Status of the connection.
protected  int isolationLevel
          Current transaction isolation level.
(package private) static java.lang.String LINE_SEPARATOR
           
protected  DatabaseMetaData metaData
          Meta-data of C-JDBC connections.
protected  java.lang.String preparedStatementBooleanFalse
           
protected  java.lang.String preparedStatementBooleanTrue
           
protected  boolean readOnly
          Is the connection in read-only mode ?
protected  java.net.Socket socket
          Connection with the controller.
protected  CJDBCInputStream socketInput
          Socket input stream.
protected  CJDBCOutputStream socketOutput
          Socket output stream.
protected  long transactionId
          transaction identifier.
protected  java.lang.String vdbPassword
           
protected  java.lang.String vdbUser
          Virtual database user used for this connection.
(package private)  boolean writeExecutedInTransaction
          Has a write request been executed in the current transaction?
 
Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
 
Constructor Summary
Connection(Driver driver, java.net.Socket socket, CJDBCInputStream in, CJDBCOutputStream out, CjdbcUrl cjdbcUrl, ControllerInfo controller, java.lang.String userName, java.lang.String password)
          Creates a new Connection instance.
 
Method Summary
 void clearWarnings()
          After this call, getWarnings() returns null until a new warning is reported for this connection.
 void close()
          Releases the connection.
 void closeRemoteResultSet(java.lang.String cursorName)
          Closes the remote ResultSet given its cursor name.
 void commit()
          Makes all changes made since the previous commit/rollback permanent and releases any database locks currently held by the Connection.
 java.sql.Statement createStatement()
          SQL statements without parameters are normally executed using Statement objects.
 java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency)
          SQL statements without parameters are normally executed using Statement objects.
 java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
          Creates a Statement object that will generate ResultSet objects with the given type, concurrency, and holdability.
protected  java.sql.ResultSet execReadRequest(SelectRequest request)
          Performs a read request and return the reply.
 java.sql.ResultSet execReadStoredProcedure(StoredProcedure proc)
          Call a stored procedure that returns a ResultSet.
protected  int execWriteRequest(AbstractWriteRequest request)
          Performs a write request and return the number of rows affected.
protected  java.sql.ResultSet execWriteRequestWithKeys(AbstractWriteRequest request)
          Performs a write request and returns the auto-generated keys
protected  int execWriteStoredProcedure(StoredProcedure proc)
          Call a stored procedure that performs an update.
 void fetchNextData(java.lang.String cursorName, int fetchSize, DriverResultSet drsToUpdate)
          Fetch next fetchSize rows of data and update the given ResultSet.
protected  void finalize()
           
protected  java.sql.ResultSet getAttributes(java.lang.String catalog, java.lang.String schemaPattern, java.lang.String typeNamePattern, java.lang.String attributeNamePattern)
           
 boolean getAutoCommit()
          Gets the current auto-commit state.
protected  java.sql.ResultSet getBestRowIdentifier(java.lang.String catalog, java.lang.String schema, java.lang.String table, int scope, boolean nullable)
           
(package private)  AbstractBlobFilter getBlobFilter()
           
 java.lang.String getCatalog()
          Return current catalog name.
 java.sql.ResultSet getCatalogs()
          getCatalogs definition.
protected  java.sql.ResultSet getColumnPrivileges(java.lang.String catalog, java.lang.String schemaPattern, java.lang.String tableName, java.lang.String columnNamePattern)
           
protected  java.sql.ResultSet getColumns(java.lang.String catalog, java.lang.String schemaPattern, java.lang.String tableNamePattern, java.lang.String columnNamePattern)
           
 ControllerInfo getControllerInfo()
          Get the information about the controller we are connected to
 java.lang.String getControllerVersionNumber()
          Get the C-JDBC controller version number.
protected  java.sql.ResultSet getCrossReference(java.lang.String primaryCatalog, java.lang.String primarySchema, java.lang.String primaryTable, java.lang.String foreignCatalog, java.lang.String foreignSchema, java.lang.String foreignTable)
           
 java.lang.String getDatabaseProductName()
           
 java.lang.String getEscapeChar()
           
 java.sql.ResultSet getExportedKeys(java.lang.String catalog, java.lang.String schema, java.lang.String table)
           
 int getHoldability()
          Retrieves the current holdability of ResultSet objects created using this Connection object.
protected  java.sql.ResultSet getImportedKeys(java.lang.String catalog, java.lang.String schema, java.lang.String table)
           
protected  java.sql.ResultSet getIndexInfo(java.lang.String catalog, java.lang.String schema, java.lang.String table, boolean unique, boolean approximate)
           
 java.sql.DatabaseMetaData getMetaData()
          A connection's database is able to provide information describing its tables, its supported SQL grammar, its stored procedures, the capabilities of this connection, etc.
 java.lang.String getPassword()
          Gets the password used to login to the database.
 java.lang.String getPreparedStatementBooleanFalse()
          Returns the booleanFalse value.
 java.lang.String getPreparedStatementBooleanTrue()
          Returns the booleanTrue value.
protected  java.sql.ResultSet getPrimaryKeys(java.lang.String catalog, java.lang.String schemaPattern, java.lang.String tableNamePattern)
           
protected  java.sql.ResultSet getProcedureColumns(java.lang.String catalog, java.lang.String schemaPattern, java.lang.String procedureNamePattern, java.lang.String columnNamePattern)
           
protected  java.sql.ResultSet getProcedures(java.lang.String catalog, java.lang.String schemaPattern, java.lang.String procedureNamePattern)
           
 java.sql.ResultSet getSchemas()
           
(package private)  java.lang.Object getStaticMetadata(java.lang.String key)
          Retrieve a static metadata from the controller.
protected  java.sql.ResultSet getSuperTables(java.lang.String catalog, java.lang.String schemaPattern, java.lang.String tableNamePattern)
           
protected  java.sql.ResultSet getSuperTypes(java.lang.String catalog, java.lang.String schemaPattern, java.lang.String typeNamePattern)
           
 java.sql.ResultSet getTablePrivileges(java.lang.String catalog, java.lang.String schemaPattern, java.lang.String tableNamePattern)
          Gets a description of the access rights for each table available in a catalog.
protected  java.sql.ResultSet getTables(java.lang.String catalog, java.lang.String schemaPattern, java.lang.String tableNamePattern, java.lang.String[] types)
           
 java.sql.ResultSet getTableTypes()
          Gets the table types available in this database.
 int getTransactionIsolation()
          Gets this Connection's current transaction isolation mode.
protected  java.sql.ResultSet getTypeInfo()
           
 java.util.Map getTypeMap()
          C-JDBC does NOT support type map.
protected  java.sql.ResultSet getUDTs(java.lang.String catalog, java.lang.String schemaPattern, java.lang.String typeNamePattern, int[] types)
           
 java.lang.String getUrl()
          Gets the C-JDBC URL of the database of the connection.
 java.lang.String getUserName()
          Gets the user name used to login to the database.
 java.sql.ResultSet getVersionColumns(java.lang.String catalog, java.lang.String schema, java.lang.String table)
           
 java.sql.SQLWarning getWarnings()
          The first warning reported by calls on this connection is returned.
 boolean isClosed()
          Returns true if the connection has been closed by the user (but C-JDBC may leave it open underneath, unknown to the user).
 boolean isConnectionPooling()
          Returns the connectionPooling value.
(package private)  boolean isDriverProcessed()
           
 boolean isEscapeBackslash()
          Returns the escapeBackslash value.
 boolean isEscapeSingleQuote()
          Returns the escapeSingleQuote value.
 boolean isReadOnly()
          Tests to see if the connection is in read only Mode.
 java.lang.String nativeSQL(java.lang.String query)
          As we can't know for sure which database will execute this request (now or later), we can't translate it in the native query language of the underlying DBMS.
 java.sql.CallableStatement prepareCall(java.lang.String sql)
          Creates a CallableStatement that contains sql and produces a ResultSet that is TYPE_SCROLL_INSENSITIVE and CONCUR_READ_ONLY.
 java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency)
          Stored procedure call are not yet supported by C-JDBC.
 java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
          Creates a CallableStatement object that will generate ResultSet objects with the given type and concurrency.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql)
          A SQL statement with or without IN parameters can be pre-compiled and stored in a PreparedStatement object.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, int autoGeneratedKeys)
          Creates a default PreparedStatement object that has the capability to retrieve auto-generated keys.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, int[] columnIndexes)
          Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency)
          A SQL statement with or without IN parameters can be pre-compiled and stored in a PreparedStatement object.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
          Creates a PreparedStatement object that will generate ResultSet objects with the given type, concurrency, and holdability.
 java.sql.PreparedStatement prepareStatement(java.lang.String sql, java.lang.String[] columnNames)
          Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array.
private  void procedureOnStream(StoredProcedure proc, boolean isRead)
          Serialize a procedure on the output stream by sending only the needed parameters to reconstruct it on the controller
private  boolean receiveBoolean()
          Returns a boolean read from the stream or throws the SerializableException that came instead.
private  SerializableException receiveException()
          Deserialize an exception from the stream: converts explicit protocol typing into java types.
private  int receiveInt()
          Returns a int read from the stream or throws the SerializableException that came instead.
private  long receiveLong()
          Returns a long read from the stream or throws the SerializableException that came instead.
private  DriverResultSet receiveResultSet(java.lang.String callerName)
          Returns a DriverResultSet read from the stream or throws the SerializableException that came instead
private  java.lang.String receiveString()
          Returns a String read from the stream or throws the SerializableException that came instead.
private  void reconnect()
          Try first to reconnect to the same controller and if we don't succeed then we notify the suspicion of failure if the current controller and we reconnect to a controller chosen using the policy specified in the JDBC URL of this connection.
 void releaseSavepoint(java.sql.Savepoint savepoint)
          Removes the given Savepoint object from the current transaction.
 void rollback()
          Drops all changes made since the previous commit/rollback and releases any database locks currently held by this connection.
 void rollback(java.sql.Savepoint savepoint)
          Undoes all changes made after the given Savepoint object was set.
private  void savepointOnStream(java.sql.Savepoint savepoint)
          Serialize a savepoint on the output stream by sending only the needed parameters to reconstruct it on the controller
 void setAutoCommit(boolean autoCommit)
          If a connection is in auto-commit mode, then all its SQL statements will be executed and committed as individual transactions.
 void setCatalog(java.lang.String catalog)
          Change the current catalog
private  void setCloseSocketOnGC(boolean closeSocketOnGC)
          Sets the closeSocketOnGC value.
private  void setConnectionParametersOnRequest(AbstractRequest request)
          Set the autocommit mode and read-only status on this request.
 void setConnectionPooling(boolean connectionPooling)
          Sets the connectionPooling value.
(package private)  void setDriverProcessed(boolean processedByDriver)
          Sets the driverProcessed value
 void setEscapeBackslash(boolean escapeBackslash)
          Sets the escapeBackslash value.
 void setEscapeChar(java.lang.String escapeChar)
          Sets the escapeCharacter value
 void setEscapeSingleQuote(boolean escapeSingleQuote)
          Sets the escapeSingleQuote value.
 void setHoldability(int holdability)
          Changes the holdability of ResultSet objects created using this Connection object to the given holdability.
 void setPreparedStatementBooleanFalse(java.lang.String booleanFalse)
          Sets the booleanFalse value.
 void setPreparedStatementBooleanTrue(java.lang.String booleanTrue)
          Sets the booleanTrue value.
 void setReadOnly(boolean readOnly)
          You can put a connection in read-only mode as a hint to enable database optimizations Note: setReadOnly cannot be called while in the middle of a transaction with write requests.
 java.sql.Savepoint setSavepoint()
          Creates an unnamed savepoint in the current transaction and returns the new Savepoint object that represents it.
 java.sql.Savepoint setSavepoint(java.lang.String name)
          Creates a savepoint with the given name in the current transaction and returns the new Savepoint object that represents it.
 void setTransactionIsolation(int level)
          You can call this method to try to change the transaction isolation level using one of the TRANSACTION_* values.
 void setTypeMap(java.util.Map map)
          C-JDBC does NOT support type map.
private  void setUrlParametersOptionsOnConnection(CjdbcUrl cjdbcUrl)
          Set CjdbcUrl parameters options on connection.
private  void throwSQLExceptionIfClosed()
           
private  void throwSQLExceptionIfClosed(java.lang.String message)
           
 java.lang.String toString()
           
private  DriverSQLException wrapIOExceptionInDriverSQLException(java.lang.String callerName, java.io.IOException ioe)
           
private  void writeRequestOnStream(AbstractWriteRequest request)
          Serialize a write request on the output stream by sending only the needed parameters to reconstruct it on the controller
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

controllerNeedsSqlSkeleton

protected boolean controllerNeedsSqlSkeleton
Does the controller wants SQL templates of PreparedStatements?


isClosed

protected boolean isClosed
Status of the connection.


escapeChar

protected java.lang.String escapeChar

controllerInfo

protected ControllerInfo controllerInfo
C-JDBC controller we are connected to


driver

protected Driver driver
Driver that created us.


socket

protected java.net.Socket socket
Connection with the controller.


socketInput

protected CJDBCInputStream socketInput
Socket input stream.


socketOutput

protected CJDBCOutputStream socketOutput
Socket output stream.


LINE_SEPARATOR

static final java.lang.String LINE_SEPARATOR

autoCommit

protected boolean autoCommit
Commit mode of the connection (true= automatic).


readOnly

protected boolean readOnly
Is the connection in read-only mode ?


writeExecutedInTransaction

boolean writeExecutedInTransaction
Has a write request been executed in the current transaction?


DEFAULT_TRANSACTION_ISOLATION_LEVEL

public static final int DEFAULT_TRANSACTION_ISOLATION_LEVEL
Default transaction isolation level if the user has not enforced one

See Also:
Constant Field Values

isolationLevel

protected int isolationLevel
Current transaction isolation level.


transactionId

protected long transactionId
transaction identifier.


firstWarning

protected java.sql.SQLWarning firstWarning
List of Warnings for this connection.


metaData

protected DatabaseMetaData metaData
Meta-data of C-JDBC connections.


cjdbcUrl

private final CjdbcUrl cjdbcUrl
Parsed URL to the database.


vdbUser

protected java.lang.String vdbUser
Virtual database user used for this connection.


vdbPassword

protected java.lang.String vdbPassword

blobFilter

private AbstractBlobFilter blobFilter

connectionPooling

private boolean connectionPooling

escapeBackslash

protected boolean escapeBackslash

escapeSingleQuote

protected boolean escapeSingleQuote

driverProcessed

protected boolean driverProcessed

preparedStatementBooleanTrue

protected java.lang.String preparedStatementBooleanTrue

preparedStatementBooleanFalse

protected java.lang.String preparedStatementBooleanFalse

closeSocketOnGC

private boolean closeSocketOnGC
Constructor Detail

Connection

public Connection(Driver driver,
                  java.net.Socket socket,
                  CJDBCInputStream in,
                  CJDBCOutputStream out,
                  CjdbcUrl cjdbcUrl,
                  ControllerInfo controller,
                  java.lang.String userName,
                  java.lang.String password)
           throws AuthenticationException,
                  java.io.IOException,
                  ProtocolException
Creates a new Connection instance.

Parameters:
driver - calling driver
socket - connection with the controller
in - socket input stream
out - socket output stream
cjdbcUrl - C-JDBC URL of the database
controller - controller we are connected to
userName - user login
password - user password
Throws:
AuthenticationException - login error
java.io.IOException - stream error
ProtocolException - unexpected answer
Method Detail

setUrlParametersOptionsOnConnection

private void setUrlParametersOptionsOnConnection(CjdbcUrl cjdbcUrl)
Set CjdbcUrl parameters options on connection.

Parameters:
cjdbcUrl - the C-JDBC URL to use

finalize

protected void finalize()
                 throws java.lang.Throwable
Throws:
java.lang.Throwable
See Also:
Object.finalize()

getUrl

public java.lang.String getUrl()
Gets the C-JDBC URL of the database of the connection.

Returns:
value of url.

getUserName

public java.lang.String getUserName()
Gets the user name used to login to the database.

Returns:
login name

getPassword

public java.lang.String getPassword()
Gets the password used to login to the database.

Returns:
password

getControllerInfo

public ControllerInfo getControllerInfo()
Get the information about the controller we are connected to

Returns:
ControllerInfo object of the controller

clearWarnings

public void clearWarnings()
After this call, getWarnings() returns null until a new warning is reported for this connection.

Specified by:
clearWarnings in interface java.sql.Connection

throwSQLExceptionIfClosed

private void throwSQLExceptionIfClosed(java.lang.String message)
                                throws DriverSQLException
Throws:
DriverSQLException
See Also:
close()

throwSQLExceptionIfClosed

private void throwSQLExceptionIfClosed()
                                throws DriverSQLException
Throws:
DriverSQLException
See Also:
close()

close

public void close()
           throws DriverSQLException
Releases the connection. In fact, the connection is marked to be released but will be effectively closed by the ConnectionClosingThread if the connection has not been reused before.

Specified by:
close in interface java.sql.Connection
Throws:
DriverSQLException - if an error occurs

commit

public void commit()
            throws DriverSQLException
Makes all changes made since the previous commit/rollback permanent and releases any database locks currently held by the Connection. This method should only be used when auto-commit has been disabled. (If autoCommit== true, then we throw a DriverSQLException).

Specified by:
commit in interface java.sql.Connection
Throws:
DriverSQLException - if a database access error occurs or the connection is in autocommit mode
See Also:
setAutoCommit(boolean)

createStatement

public java.sql.Statement createStatement()
                                   throws DriverSQLException
SQL statements without parameters are normally executed using Statement objects. If the same SQL statement is executed many times, it is more efficient to use a PreparedStatement. The ResultSet will be TYPE_FORWARD_ONLY/CONCUR_READ_ONLY. *

Specified by:
createStatement in interface java.sql.Connection
Returns:
a new Statement object
Throws:
DriverSQLException - passed through from the constructor

createStatement

public java.sql.Statement createStatement(int resultSetType,
                                          int resultSetConcurrency)
                                   throws java.sql.SQLException
SQL statements without parameters are normally executed using Statement objects. If the same SQL statement is executed many times, it is more efficient to use a PreparedStatement.

Specified by:
createStatement in interface java.sql.Connection
Parameters:
resultSetType - resultSetType to use
resultSetConcurrency - resultSetConcurrency to use
Returns:
a new Statement object
Throws:
java.sql.SQLException - passed through from the constructor

getAutoCommit

public boolean getAutoCommit()
                      throws DriverSQLException
Gets the current auto-commit state.

Specified by:
getAutoCommit in interface java.sql.Connection
Returns:
current state of the auto-commit mode
Throws:
DriverSQLException - is connection is closed
See Also:
setAutoCommit(boolean)

getMetaData

public java.sql.DatabaseMetaData getMetaData()
                                      throws DriverSQLException
A connection's database is able to provide information describing its tables, its supported SQL grammar, its stored procedures, the capabilities of this connection, etc. This information is made available through a DatabaseMetaData object.

Specified by:
getMetaData in interface java.sql.Connection
Returns:
a DatabaseMetaData object for this connection
Throws:
DriverSQLException - if connection is closed

getCatalog

public java.lang.String getCatalog()
                            throws DriverSQLException
Return current catalog name.

Specified by:
getCatalog in interface java.sql.Connection
Returns:
name of the current VirtualDatabase
Throws:
DriverSQLException - if any error occurs
See Also:
getCatalog()

getCatalogs

public java.sql.ResultSet getCatalogs()
                               throws DriverSQLException
getCatalogs definition.

Returns:
instace of ResultSet
Throws:
DriverSQLException - if fails (include ANY exception that can be thrown in the code)

getProcedures

protected java.sql.ResultSet getProcedures(java.lang.String catalog,
                                           java.lang.String schemaPattern,
                                           java.lang.String procedureNamePattern)
                                    throws DriverSQLException
Throws:
DriverSQLException

getProcedureColumns

protected java.sql.ResultSet getProcedureColumns(java.lang.String catalog,
                                                 java.lang.String schemaPattern,
                                                 java.lang.String procedureNamePattern,
                                                 java.lang.String columnNamePattern)
                                          throws DriverSQLException
Throws:
DriverSQLException

getTransactionIsolation

public int getTransactionIsolation()
                            throws DriverSQLException
Gets this Connection's current transaction isolation mode. If the transaction isolation has not been set using setTransactionIsolation, this method will return by default java.sql.Connection.TRANSACTION_READ_UNCOMMITTED whatever transaction isolation is really used by the cluster nodes. If you want to enfore TRANSACTION_READ_UNCOMMITTED, you have to explicitely call setTransactionIsolation(java.sql.Connection.TRANSACTION_READ_UNCOMMITTED)

Specified by:
getTransactionIsolation in interface java.sql.Connection
Returns:
the current TRANSACTION_* mode value
Throws:
DriverSQLException - if a database access error occurs
See Also:
setTransactionIsolation(int)

getTypeMap

public java.util.Map getTypeMap()
                         throws java.sql.SQLException
C-JDBC does NOT support type map.

Specified by:
getTypeMap in interface java.sql.Connection
Returns:
an exception
Throws:
java.sql.SQLException - not supported

getWarnings

public java.sql.SQLWarning getWarnings()
The first warning reported by calls on this connection is returned. Note: Sebsequent warnings will be changed to this SQLWarning

Specified by:
getWarnings in interface java.sql.Connection
Returns:
the first SQLWarning or null

isClosed

public boolean isClosed()
Returns true if the connection has been closed by the user (but C-JDBC may leave it open underneath, unknown to the user).

Specified by:
isClosed in interface java.sql.Connection
Returns:
true if connection has never been opened or close() has been called

isReadOnly

public boolean isReadOnly()
Tests to see if the connection is in read only Mode. Note that we cannot really put the database in read only mode, but we pretend we can by returning the value of the readOnly flag.

Specified by:
isReadOnly in interface java.sql.Connection
Returns:
true if the connection is read only

nativeSQL

public java.lang.String nativeSQL(java.lang.String query)
As we can't know for sure which database will execute this request (now or later), we can't translate it in the native query language of the underlying DBMS. Therefore the query is returned unchanged.

Specified by:
nativeSQL in interface java.sql.Connection
Parameters:
query - the query to change
Returns:
the original query

prepareCall

public java.sql.CallableStatement prepareCall(java.lang.String sql)
                                       throws java.sql.SQLException
Creates a CallableStatement that contains sql and produces a ResultSet that is TYPE_SCROLL_INSENSITIVE and CONCUR_READ_ONLY.

Specified by:
prepareCall in interface java.sql.Connection
Parameters:
sql - SQL request
Returns:
nothing
Throws:
java.sql.SQLException - not supported

prepareCall

public java.sql.CallableStatement prepareCall(java.lang.String sql,
                                              int resultSetType,
                                              int resultSetConcurrency)
                                       throws java.sql.SQLException
Stored procedure call are not yet supported by C-JDBC.

Specified by:
prepareCall in interface java.sql.Connection
Parameters:
sql - a String value
resultSetType - an int value
resultSetConcurrency - an int value
Returns:
nothing
Throws:
java.sql.SQLException - not supported

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql)
                                            throws java.sql.SQLException
A SQL statement with or without IN parameters can be pre-compiled and stored in a PreparedStatement object. This object can then be used to efficiently execute this statement multiple times.

Specified by:
prepareStatement in interface java.sql.Connection
Parameters:
sql - a SQL statement that may contain one or more '?' IN * parameter placeholders
Returns:
a new PreparedStatement object containing the pre-compiled statement.
Throws:
java.sql.SQLException - if a database access error occurs.

prepareStatement

public java.sql.PreparedStatement prepareStatement(java.lang.String sql,
                                                   int resultSetType,
                                                   int resultSetConcurrency)
                                            throws java.sql.SQLException
A SQL statement with or without IN parameters can be pre-compiled and stored in a PreparedStatement object. This object can then be used to efficiently execute this statement multiple times.

Specified by:
prepareStatement in interface java.sql.Connection
Parameters:
sql - a SQL statement that may contain one or more '?' IN
resultSetType - ResultSetType to use
resultSetConcurrency - ResultSetConcurrency to use
Returns:
a new PreparedStatement object
Throws:
java.sql.SQLException - passed through from the constructor

rollback

public void rollback()
              throws DriverSQLException
Drops all changes made since the previous commit/rollback and releases any database locks currently held by this connection. If the connection was in autocommit mode, we throw a DriverSQLException.

Specified by:
rollback in interface java.sql.Connection
Throws:
DriverSQLException - if a database access error occurs or the connection is in autocommit mode
See Also:
commit()

setAutoCommit

public void setAutoCommit(boolean autoCommit)
                   throws DriverSQLException
If a connection is in auto-commit mode, then all its SQL statements will be executed and committed as individual transactions. Otherwise, its SQL statements are grouped into transactions that are terminated by either commit()or rollback(). By default, new connections are in auto-commit mode. The commit occurs when the statement completes or the next execute occurs, whichever comes first. In the case of statements returning a ResultSet, the statement completes when the last row of the ResultSet has been retrieved or the ResultSet has been closed. In advanced cases, a single statement may return multiple results as well as output parameter values. Here the commit occurs when all results and output param values have been retrieved.

Specified by:
setAutoCommit in interface java.sql.Connection
Parameters:
autoCommit - true enables auto-commit; false disables it
Throws:
DriverSQLException - if a database access error occurs

setCatalog

public void setCatalog(java.lang.String catalog)
                throws java.sql.SQLException
Change the current catalog

Specified by:
setCatalog in interface java.sql.Connection
Parameters:
catalog - a String value
Throws:
java.sql.SQLException - if fails or if catalog name is invalid

setReadOnly

public void setReadOnly(boolean readOnly)
                 throws DriverSQLException
You can put a connection in read-only mode as a hint to enable database optimizations

Note: setReadOnly cannot be called while in the middle of a transaction with write requests.

Specified by:
setReadOnly in interface java.sql.Connection
Parameters:
readOnly - true enables read-only mode; false disables it
Throws:
DriverSQLException - if a database access error occurs

setTransactionIsolation

public void setTransactionIsolation(int level)
                             throws DriverSQLException
You can call this method to try to change the transaction isolation level using one of the TRANSACTION_* values.

Note: this method cannot be called while in the middle of a transaction.

Specified by:
setTransactionIsolation in interface java.sql.Connection
Parameters:
level - one of the TRANSACTION_* isolation values with * the exception of TRANSACTION_NONE; some databases may * not support other values
Throws:
DriverSQLException - if a database access error occurs
See Also:
DatabaseMetaData.supportsTransactionIsolationLevel(int)

setTypeMap

public void setTypeMap(java.util.Map map)
                throws java.sql.SQLException
C-JDBC does NOT support type map.

Specified by:
setTypeMap in interface java.sql.Connection
Parameters:
map - ignored
Throws:
java.sql.SQLException - not supported

setCloseSocketOnGC

private void setCloseSocketOnGC(boolean closeSocketOnGC)
Sets the closeSocketOnGC value.

Parameters:
closeSocketOnGC - The closeSocketOnGC to set.

setConnectionParametersOnRequest

private void setConnectionParametersOnRequest(AbstractRequest request)
Set the autocommit mode and read-only status on this request.

Parameters:
request - The request to set

receiveResultSet

private DriverResultSet receiveResultSet(java.lang.String callerName)
                                  throws java.io.IOException,
                                         ProtocolException,
                                         SerializableException
Returns a DriverResultSet read from the stream or throws the SerializableException that came instead

Parameters:
callerName - used for error messages. Is this really useful?
Returns:
received ResultSet
Throws:
java.io.IOException - stream or protocol error
SerializableException - received from the controller
ProtocolException

procedureOnStream

private void procedureOnStream(StoredProcedure proc,
                               boolean isRead)
                        throws java.io.IOException
Serialize a procedure on the output stream by sending only the needed parameters to reconstruct it on the controller

Parameters:
proc - the procedure to send
isRead - true if this is a read stored procedure
Throws:
java.io.IOException - if fails

writeRequestOnStream

private void writeRequestOnStream(AbstractWriteRequest request)
                           throws java.io.IOException
Serialize a write request on the output stream by sending only the needed parameters to reconstruct it on the controller

Parameters:
request - the write request to send
Throws:
java.io.IOException - if fails

receiveException

private SerializableException receiveException()
                                        throws java.io.IOException
Deserialize an exception from the stream: converts explicit protocol typing into java types.

Returns:
the deserialized exception read from the stream
Throws:
java.io.IOException - stream error

receiveString

private java.lang.String receiveString()
                                throws java.io.IOException,
                                       SerializableException
Returns a String read from the stream or throws the SerializableException that came instead.

Throws:
java.io.IOException - stream or protocol error
SerializableException - coming from the controller

receiveBoolean

private boolean receiveBoolean()
                        throws java.io.IOException,
                               SerializableException
Returns a boolean read from the stream or throws the SerializableException that came instead.

Throws:
java.io.IOException - stream or protocol error
SerializableException - coming from the controller

receiveInt

private int receiveInt()
                throws java.io.IOException,
                       SerializableException
Returns a int read from the stream or throws the SerializableException that came instead.

Throws:
java.io.IOException - stream or protocol error
SerializableException - coming from the controller

receiveLong

private long receiveLong()
                  throws java.io.IOException,
                         SerializableException
Returns a long read from the stream or throws the SerializableException that came instead.

Throws:
java.io.IOException - stream or protocol error
SerializableException - coming from the controller

savepointOnStream

private void savepointOnStream(java.sql.Savepoint savepoint)
                        throws java.io.IOException
Serialize a savepoint on the output stream by sending only the needed parameters to reconstruct it on the controller

Parameters:
savepoint - the savepoint to send
Throws:
java.io.IOException - if fails

reconnect

private void reconnect()
                throws DriverSQLException
Try first to reconnect to the same controller and if we don't succeed then we notify the suspicion of failure if the current controller and we reconnect to a controller chosen using the policy specified in the JDBC URL of this connection. FIXME: we need a less coarse exception signature

Throws:
DriverSQLException - if an error occured during reconnect

execReadRequest

protected java.sql.ResultSet execReadRequest(SelectRequest request)
                                      throws DriverSQLException
Performs a read request and return the reply.

Parameters:
request - the read request to execute
Returns:
a java.sql.ResultSet value
Throws:
DriverSQLException - if an error occurs

execWriteRequest

protected int execWriteRequest(AbstractWriteRequest request)
                        throws DriverSQLException
Performs a write request and return the number of rows affected.

Parameters:
request - the write request to execute
Returns:
number of rows affected
Throws:
DriverSQLException - if an error occurs

execWriteRequestWithKeys

protected java.sql.ResultSet execWriteRequestWithKeys(AbstractWriteRequest request)
                                               throws DriverSQLException
Performs a write request and returns the auto-generated keys

Parameters:
request - the write request to execute
Returns:
auto generated keys
Throws:
DriverSQLException - if an error occurs

execReadStoredProcedure

public java.sql.ResultSet execReadStoredProcedure(StoredProcedure proc)
                                           throws DriverSQLException
Call a stored procedure that returns a ResultSet.

Parameters:
proc - the stored procedure call
Returns:
a java.sql.ResultSet value
Throws:
DriverSQLException - if an error occurs

execWriteStoredProcedure

protected int execWriteStoredProcedure(StoredProcedure proc)
                                throws DriverSQLException
Call a stored procedure that performs an update.

Parameters:
proc - the stored procedure call
Returns:
number of rows affected
Throws:
DriverSQLException - if an error occurs

getBlobFilter

AbstractBlobFilter getBlobFilter()
See Also:
getBlobFilter()

getAttributes

protected java.sql.ResultSet getAttributes(java.lang.String catalog,
                                           java.lang.String schemaPattern,
                                           java.lang.String typeNamePattern,
                                           java.lang.String attributeNamePattern)
                                    throws DriverSQLException
Throws:
DriverSQLException
See Also:
DatabaseMetaData.getAttributes(java.lang.String, java.lang.String, java.lang.String, java.lang.String)

getBestRowIdentifier

protected java.sql.ResultSet getBestRowIdentifier(java.lang.String catalog,
                                                  java.lang.String schema,
                                                  java.lang.String table,
                                                  int scope,
                                                  boolean nullable)
                                           throws DriverSQLException
Throws:
DriverSQLException
See Also:
DatabaseMetaData.getBestRowIdentifier(java.lang.String, java.lang.String, java.lang.String, int, boolean)

getColumnPrivileges

protected java.sql.ResultSet getColumnPrivileges(java.lang.String catalog,
                                                 java.lang.String schemaPattern,
                                                 java.lang.String tableName,
                                                 java.lang.String columnNamePattern)
                                          throws DriverSQLException
Throws:
DriverSQLException
See Also:
DatabaseMetaData.getColumnPrivileges(java.lang.String, java.lang.String, java.lang.String, java.lang.String)

getColumns

protected java.sql.ResultSet getColumns(java.lang.String catalog,
                                        java.lang.String schemaPattern,
                                        java.lang.String tableNamePattern,
                                        java.lang.String columnNamePattern)
                                 throws DriverSQLException
Throws:
DriverSQLException
See Also:
DatabaseMetaData.getColumns(java.lang.String, java.lang.String, java.lang.String, java.lang.String)

getCrossReference

protected java.sql.ResultSet getCrossReference(java.lang.String primaryCatalog,
                                               java.lang.String primarySchema,
                                               java.lang.String primaryTable,
                                               java.lang.String foreignCatalog,
                                               java.lang.String foreignSch