org.firebirdsql.jdbc
Class FBConnection

java.lang.Object
  extended by org.firebirdsql.jdbc.AbstractConnection
      extended by org.firebirdsql.jdbc.FBConnection
All Implemented Interfaces:
Connection, Wrapper, FirebirdConnection

public class FBConnection
extends AbstractConnection

Firebird connection class implementing JDBC 3.0 methods.

Author:
Roman Rokytskyy

Field Summary
 
Fields inherited from class org.firebirdsql.jdbc.AbstractConnection
mc, txCoordinator
 
Fields inherited from interface org.firebirdsql.jdbc.FirebirdConnection
TPB_CONCURRENCY, TPB_CONSISTENCY, TPB_NO_REC_VERSION, TPB_NOWAIT, TPB_READ, TPB_READ_COMMITTED, TPB_REC_VERSION, TPB_WAIT, TPB_WRITE
 
Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
 
Constructor Summary
FBConnection(FBManagedConnection mc)
          Create instance of this class for the specified managed connection.
 
Method Summary
 Array createArrayOf(String typeName, Object[] elements)
           
 Clob createClob()
           
 NClob createNClob()
           
 SQLXML createSQLXML()
           
 Struct createStruct(String typeName, Object[] attributes)
           
 Properties getClientInfo()
           
 String getClientInfo(String name)
           
 boolean isValid(int timeout)
           
 boolean isWrapperFor(Class arg0)
           
 PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
          Creates a default PreparedStatement object that has the capability to retrieve auto-generated keys.
 PreparedStatement prepareStatement(String sql, int[] columnIndexes)
          Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array.
 PreparedStatement prepareStatement(String sql, String[] columnNames)
          Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array.
 void releaseSavepoint(Savepoint savepoint)
          Removes the given Savepoint object from the current transaction.
 void rollback(Savepoint savepoint)
          Undoes all changes made after the given Savepoint object was set.
 void setClientInfo(Properties properties)
           
 void setClientInfo(String name, String value)
           
 Savepoint setSavepoint()
          Creates an unnamed savepoint in the current transaction and returns the new Savepoint object that represents it.
 Savepoint setSavepoint(String name)
          Creates a savepoint with the given name in the current transaction and returns the new Savepoint object that represents it.
 Object unwrap(Class arg0)
           
 
Methods inherited from class org.firebirdsql.jdbc.AbstractConnection
addWarning, clearWarnings, close, commit, createBlob, createStatement, createStatement, createStatement, createTransactionParameterBuffer, finalize, getAutoCommit, getCatalog, getDatabaseParameterBuffer, getGDSHelper, getHoldability, getInternalAPIHandler, getIscDBHandle, getIscEncoding, getLocalTransaction, getMetaData, getStatementListener, getTransactionIsolation, getTransactionParameters, getTypeMap, getWarnings, inTransaction, invalidateSavepoints, isClosed, isReadOnly, nativeSQL, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, releaseSavepoint, rollback, rollback, setAutoCommit, setCatalog, setFirebirdSavepoint, setFirebirdSavepoint, setHoldability, setManagedConnection, setManagedEnvironment, setReadOnly, setTransactionIsolation, setTransactionParameters, setTransactionParameters, setTransactionParameters, setTypeMap
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FBConnection

public FBConnection(FBManagedConnection mc)
Create instance of this class for the specified managed connection.

Parameters:
mc - managed connection.
Method Detail

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          int autoGeneratedKeys)
                                   throws SQLException
Creates a default PreparedStatement object that has the capability to retrieve auto-generated keys. The given constant tells the driver whether it should make auto-generated keys available for retrieval. This parameter is ignored if the SQL statement is not an INSERT statement.

Note: This method is optimized for handling parametric SQL statements that benefit from precompilation. If the driver supports precompilation, the method prepareStatement will send the statement to the database for precompilation. Some drivers may not support precompilation. In this case, the statement may not be sent to the database until the PreparedStatement object is executed. This has no direct effect on users; however, it does affect which methods throw certain SQLExceptions.

Result sets created using the returned PreparedStatement object will by default be type TYPE_FORWARD_ONLY and have a concurrency level of CONCUR_READ_ONLY.

Parameters:
sql - an SQL statement that may contain one or more '?' IN parameter placeholders
autoGeneratedKeys - a flag indicating whether auto-generated keys should be returned; one of Statement.RETURN_GENERATED_KEYS or Statement.NO_GENERATED_KEYS
Returns:
a new PreparedStatement object, containing the pre-compiled SQL statement, that will have the capability of returning auto-generated keys
Throws:
SQLException - if a database access error occurs or the given parameter is not a Statement constant indicating whether auto-generated keys should be returned

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          int[] columnIndexes)
                                   throws SQLException
Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array. This array contains the indexes of the columns in the target table that contain the auto-generated keys that should be made available. This array is ignored if the SQL statement is not an INSERT statement.

An 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.

Note: This method is optimized for handling parametric SQL statements that benefit from precompilation. If the driver supports precompilation, the method prepareStatement will send the statement to the database for precompilation. Some drivers may not support precompilation. In this case, the statement may not be sent to the database until the PreparedStatement object is executed. This has no direct effect on users; however, it does affect which methods throw certain SQLExceptions.

Result sets created using the returned PreparedStatement object will by default be type TYPE_FORWARD_ONLY and have a concurrency level of CONCUR_READ_ONLY.

Parameters:
sql - an SQL statement that may contain one or more '?' IN parameter placeholders
columnIndexes - an array of column indexes indicating the columns that should be returned from the inserted row or rows
Returns:
a new PreparedStatement object, containing the pre-compiled statement, that is capable of returning the auto-generated keys designated by the given array of column indexes
Throws:
SQLException - if a database access error occurs

prepareStatement

public PreparedStatement prepareStatement(String sql,
                                          String[] columnNames)
                                   throws SQLException
Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array. This array contains the names of the columns in the target table that contain the auto-generated keys that should be returned. This array is ignored if the SQL statement is not an INSERT statement.

An 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.

Note: This method is optimized for handling parametric SQL statements that benefit from precompilation. If the driver supports precompilation, the method prepareStatement will send the statement to the database for precompilation. Some drivers may not support precompilation. In this case, the statement may not be sent to the database until the PreparedStatement object is executed. This has no direct effect on users; however, it does affect which methods throw certain SQLExceptions.

Result sets created using the returned PreparedStatement object will by default be type TYPE_FORWARD_ONLY and have a concurrency level of CONCUR_READ_ONLY.

Parameters:
sql - an SQL statement that may contain one or more '?' IN parameter placeholders
columnNames - an array of column names indicating the columns that should be returned from the inserted row or rows
Returns:
a new PreparedStatement object, containing the pre-compiled statement, that is capable of returning the auto-generated keys designated by the given array of column names
Throws:
SQLException - if a database access error occurs

setSavepoint

public Savepoint setSavepoint()
                       throws SQLException
Creates an unnamed savepoint in the current transaction and returns the new Savepoint object that represents it.

Returns:
the new Savepoint object
Throws:
SQLException - if a database access error occurs or this Connection object is currently in auto-commit mode
Since:
1.4
See Also:
Savepoint

setSavepoint

public Savepoint setSavepoint(String name)
                       throws SQLException
Creates a savepoint with the given name in the current transaction and returns the new Savepoint object that represents it.

Parameters:
name - a String containing the name of the savepoint
Returns:
the new Savepoint object
Throws:
SQLException - if a database access error occurs or this Connection object is currently in auto-commit mode
Since:
1.4
See Also:
Savepoint

rollback

public void rollback(Savepoint savepoint)
              throws SQLException
Undoes all changes made after the given Savepoint object was set.

This method should be used only when auto-commit has been disabled.

Parameters:
savepoint - the Savepoint object to roll back to
Throws:
SQLException - if a database access error occurs, the Savepoint object is no longer valid, or this Connection object is currently in auto-commit mode
Since:
1.4
See Also:
Savepoint, rollback(java.sql.Savepoint)

releaseSavepoint

public void releaseSavepoint(Savepoint savepoint)
                      throws SQLException
Removes the given Savepoint object from the current transaction. Any reference to the savepoint after it have been removed will cause an SQLException to be thrown.

Parameters:
savepoint - the Savepoint object to be removed
Throws:
SQLException - if a database access error occurs or the given Savepoint object is not a valid savepoint in the current transaction
Since:
1.4

createArrayOf

public Array createArrayOf(String typeName,
                           Object[] elements)
                    throws SQLException
Throws:
SQLException

createClob

public Clob createClob()
                throws SQLException
Throws:
SQLException

createNClob

public NClob createNClob()
                  throws SQLException
Throws:
SQLException

createSQLXML

public SQLXML createSQLXML()
                    throws SQLException
Throws:
SQLException

createStruct

public Struct createStruct(String typeName,
                           Object[] attributes)
                    throws SQLException
Throws:
SQLException

getClientInfo

public Properties getClientInfo()
                         throws SQLException
Throws:
SQLException

getClientInfo

public String getClientInfo(String name)
                     throws SQLException
Throws:
SQLException

isValid

public boolean isValid(int timeout)
                throws SQLException
Throws:
SQLException

setClientInfo

public void setClientInfo(Properties properties)
                   throws SQLClientInfoException
Throws:
SQLClientInfoException

setClientInfo

public void setClientInfo(String name,
                          String value)
                   throws SQLClientInfoException
Throws:
SQLClientInfoException

isWrapperFor

public boolean isWrapperFor(Class arg0)
                     throws SQLException
Throws:
SQLException

unwrap

public Object unwrap(Class arg0)
              throws SQLException
Throws:
SQLException


Copyright © 2001-2010. All Rights Reserved.