Save This Page
Home » spring-framework-2.5.6-with-dependencies » org.springframework » jdbc » datasource » [javadoc | source]
org.springframework.jdbc.datasource
public class: ConnectionHolder [javadoc | source]
java.lang.Object
   org.springframework.transaction.support.ResourceHolderSupport
      org.springframework.jdbc.datasource.ConnectionHolder

All Implemented Interfaces:
    ResourceHolder

Connection holder, wrapping a JDBC Connection. DataSourceTransactionManager binds instances of this class to the thread, for a specific DataSource.

Inherits rollback-only support for nested JDBC transactions and reference count functionality from the base class.

Note: This is an SPI class, not intended to be used by applications.

Field Summary
public static final  String SAVEPOINT_NAME_PREFIX     
Constructor:
 public ConnectionHolder(ConnectionHandle connectionHandle) 
    Create a new ConnectionHolder for the given ConnectionHandle.
    Parameters:
    connectionHandle - the ConnectionHandle to hold
 public ConnectionHolder(Connection connection) 
    Create a new ConnectionHolder for the given JDBC Connection, wrapping it with a SimpleConnectionHandle , assuming that there is no ongoing transaction.
 public ConnectionHolder(Connection connection,
    boolean transactionActive) 
    Parameters:
    connection - the JDBC Connection to hold
    transactionActive - whether the given Connection is involved in an ongoing transaction
    Also see:
    SimpleConnectionHandle
Method from org.springframework.jdbc.datasource.ConnectionHolder Summary:
clear,   createSavepoint,   getConnection,   getConnectionHandle,   hasConnection,   isTransactionActive,   released,   setConnection,   setTransactionActive,   supportsSavepoints
Methods from org.springframework.transaction.support.ResourceHolderSupport:
clear,   getDeadline,   getTimeToLiveInMillis,   getTimeToLiveInSeconds,   hasTimeout,   isOpen,   isRollbackOnly,   isSynchronizedWithTransaction,   isVoid,   released,   requested,   reset,   setRollbackOnly,   setSynchronizedWithTransaction,   setTimeoutInMillis,   setTimeoutInSeconds,   unbound
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.springframework.jdbc.datasource.ConnectionHolder Detail:
 public  void clear() 
 public Savepoint createSavepoint() throws SQLException 
    Create a new JDBC 3.0 Savepoint for the current Connection, using generated savepoint names that are unique for the Connection.
 public Connection getConnection() 
    Return the current Connection held by this ConnectionHolder.

    This will be the same Connection until released gets called on the ConnectionHolder, which will reset the held Connection, fetching a new Connection on demand.

 public ConnectionHandle getConnectionHandle() 
    Return the ConnectionHandle held by this ConnectionHolder.
 protected boolean hasConnection() 
    Return whether this holder currently has a Connection.
 protected boolean isTransactionActive() 
    Return whether this holder represents an active, JDBC-managed transaction.
 public  void released() 
    Releases the current Connection held by this ConnectionHolder.

    This is necessary for ConnectionHandles that expect "Connection borrowing", where each returned Connection is only temporarily leased and needs to be returned once the data operation is done, to make the Connection available for other operations within the same transaction. This is the case with JDO 2.0 DataStoreConnections, for example.

 protected  void setConnection(Connection connection) 
    Override the existing Connection handle with the given Connection. Reset the handle if given null.

    Used for releasing the Connection on suspend (with a null argument) and setting a fresh Connection on resume.

 protected  void setTransactionActive(boolean transactionActive) 
    Set whether this holder represents an active, JDBC-managed transaction.
 public boolean supportsSavepoints() throws SQLException 
    Return whether JDBC 3.0 Savepoints are supported. Caches the flag for the lifetime of this ConnectionHolder.