public abstract class ConnectionHolder extends Object implements Connection
Modifier and Type | Class and Description |
---|---|
static class |
ConnectionHolder.ConnectionType |
Modifier and Type | Field and Description |
---|---|
protected boolean |
active |
protected Connection |
con |
protected boolean |
isClosed |
protected ManagedConnectionImpl |
mc |
protected static StringManager |
sm
The active flag is false when the connection handle is
created.
|
protected int |
statementTimeout |
protected boolean |
statementTimeoutEnabled |
protected boolean |
valid |
protected boolean |
wrappedAlready |
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
Constructor and Description |
---|
ConnectionHolder(Connection con,
ManagedConnectionImpl mc,
javax.resource.spi.ConnectionRequestInfo cxRequestInfo)
Constructs a Connection holder.
|
Modifier and Type | Method and Description |
---|---|
void |
associateConnection(Connection con,
ManagedConnectionImpl mc)
Replace the actual
java.sql.Connection object with the one
supplied. |
protected void |
checkValidity()
Checks the validity of this object
|
void |
clearWarnings()
Clears all warnings reported for the underlying connection object.
|
void |
close()
Closes the logical connection.
|
void |
commit()
Commit the changes in the underlying Connection.
|
Statement |
createStatement()
Creates a statement from the underlying Connection
|
Statement |
createStatement(int resultSetType,
int resultSetConcurrency)
Creates a statement from the underlying Connection.
|
Statement |
createStatement(int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
Creates a statement from the underlying Connection.
|
void |
dissociateConnection()
Dis-associate ManagedConnection and actual-connection from this user connection.
|
boolean |
getAutoCommit()
Retrieves the current auto-commit mode for the underlying
Connection . |
String |
getCatalog()
Retrieves the underlying
Connection object's catalog name. |
Connection |
getConnection()
Returns the actual connection in this holder object.
|
ConnectionHolder.ConnectionType |
getConnectionType() |
int |
getHoldability()
Retrieves the current holdability of
ResultSet objects created
using this connection object. |
ManagedConnectionImpl |
getManagedConnection()
Returns the
ManagedConnection instance responsible
for this connection. |
DatabaseMetaData |
getMetaData()
Retrieves the
DatabaseMetaData object from the underlying
Connection object. |
protected MethodExecutor |
getMethodExecutor() |
int |
getTransactionIsolation()
Retrieves this
Connection object's current transaction isolation level. |
Map<String,Class<?>> |
getTypeMap()
Retrieves the
Map object associated with
Connection Object. |
SQLWarning |
getWarnings()
Retrieves the the first warning reported by calls on the underlying
Connection object. |
void |
invalidate()
Invalidates this object.
|
boolean |
isClosed()
Retrieves whether underlying
Connection object is closed. |
boolean |
isReadOnly()
Retrieves whether this
Connection object is read-only. |
boolean |
isWrapped()
Returns whether it is wrapped already or not.
|
protected void |
jdbcPreInvoke() |
String |
nativeSQL(String sql)
Converts the given SQL statement into the system's native SQL grammer.
|
protected void |
performLazyAssociation() |
protected void |
performLazyEnlistment() |
CallableStatement |
prepareCall(String sql)
Creates a
CallableStatement object for calling database
stored procedures. |
CallableStatement |
prepareCall(String sql,
int resultSetType,
int resultSetConcurrency)
Creates a
CallableStatement object for calling database
stored procedures. |
CallableStatement |
prepareCall(String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
Creates a
CallableStatement object for calling database
stored procedures. |
PreparedStatement |
prepareStatement(String sql)
Creates a
PreparedStatement object for sending
paramterized SQL statements to database |
PreparedStatement |
prepareStatement(String sql,
int autoGeneratedKeys)
Creates a
PreparedStatement object for sending
paramterized SQL statements to database |
PreparedStatement |
prepareStatement(String sql,
int[] columnIndexes)
Creates a
PreparedStatement object for sending
paramterized SQL statements to database |
PreparedStatement |
prepareStatement(String sql,
int resultSetType,
int resultSetConcurrency)
Creates a
PreparedStatement object for sending
paramterized SQL statements to database |
PreparedStatement |
prepareStatement(String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
Creates a
PreparedStatement object for sending
paramterized SQL statements to database |
PreparedStatement |
prepareStatement(String sql,
String[] columnNames)
Creates a
PreparedStatement object for sending
paramterized SQL statements to database |
void |
releaseSavepoint(Savepoint savepoint)
Removes the given
Savepoint object from the current transaction. |
void |
rollback()
Rolls back the changes made in the current transaction.
|
void |
rollback(Savepoint savepoint)
Rolls back the changes made after the savepoint.
|
void |
setActive(boolean actv)
Sets the active flag to true
|
void |
setAutoCommit(boolean autoCommit)
Sets the auto-commmit mode of the
Connection object. |
void |
setCatalog(String catalog)
Sets the catalog name to the
Connection object |
void |
setClosed(boolean flag)
Set the isClosed flag based on whether the underlying
Connection
object is closed. |
void |
setConnectionType(ConnectionHolder.ConnectionType type) |
void |
setHoldability(int holdability)
Sets the holdability of
ResultSet objects created
using this Connection object. |
void |
setLazyAssociatableConnectionManager(javax.resource.spi.LazyAssociatableConnectionManager cm) |
void |
setLazyEnlistableConnectionManager(javax.resource.spi.LazyEnlistableConnectionManager cm) |
void |
setReadOnly(boolean readOnly)
Puts the connection in read-only mode as a hint to the driver to
perform database optimizations.
|
Savepoint |
setSavepoint()
Creates and unnamed savepoint and returns an object corresponding to that.
|
Savepoint |
setSavepoint(String name)
Creates a savepoint with the name and returns an object corresponding to that.
|
void |
setTransactionIsolation(int level)
Creates the transaction isolation level.
|
void |
setTypeMap(Map<String,Class<?>> map)
Installs the given
Map object as the tyoe map for this
Connection object. |
void |
wrapped(boolean wrapFlag)
Sets the flag to indicate that, the connection is wrapped already or not.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
abort, createArrayOf, createBlob, createClob, createNClob, createSQLXML, createStruct, getClientInfo, getClientInfo, getNetworkTimeout, getSchema, isValid, setClientInfo, setClientInfo, setNetworkTimeout, setSchema
isWrapperFor, unwrap
protected Connection con
protected ManagedConnectionImpl mc
protected boolean wrappedAlready
protected boolean isClosed
protected boolean valid
protected boolean active
protected int statementTimeout
protected boolean statementTimeoutEnabled
protected static final StringManager sm
public ConnectionHolder(Connection con, ManagedConnectionImpl mc, javax.resource.spi.ConnectionRequestInfo cxRequestInfo)
con
- java.sql.Connection
object.public Connection getConnection() throws SQLException
SQLException
public void wrapped(boolean wrapFlag)
wrapFlag
- public boolean isWrapped()
public ManagedConnectionImpl getManagedConnection()
ManagedConnection
instance responsible
for this connection.ManagedConnection
instance.public void associateConnection(Connection con, ManagedConnectionImpl mc)
java.sql.Connection
object with the one
supplied. Also replace ManagedConnection
link.con
- Connection
object.mc
- ManagedConnection
object.public void dissociateConnection()
public void clearWarnings() throws SQLException
clearWarnings
in interface Connection
SQLException
- In case of a database error.public void close() throws SQLException
close
in interface AutoCloseable
close
in interface Connection
SQLException
- In case of a database error.public void invalidate()
public void commit() throws SQLException
commit
in interface Connection
SQLException
- In case of a database error.public Statement createStatement() throws SQLException
createStatement
in interface Connection
Statement
object.SQLException
- In case of a database error.public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException
createStatement
in interface Connection
resultSetType
- Type of the ResultSetresultSetConcurrency
- ResultSet Concurrency.Statement
object.SQLException
- In case of a database error.public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
createStatement
in interface Connection
resultSetType
- Type of the ResultSetresultSetConcurrency
- ResultSet Concurrency.resultSetHoldability
- ResultSet Holdability.Statement
object.SQLException
- In case of a database error.public boolean getAutoCommit() throws SQLException
Connection
.getAutoCommit
in interface Connection
SQLException
- In case of a database error.public String getCatalog() throws SQLException
Connection
object's catalog name.getCatalog
in interface Connection
SQLException
- In case of a database error.public int getHoldability() throws SQLException
ResultSet
objects created
using this connection object.getHoldability
in interface Connection
SQLException
- In case of a database error.public DatabaseMetaData getMetaData() throws SQLException
DatabaseMetaData
object from the underlying
Connection
object.getMetaData
in interface Connection
DatabaseMetaData
object.SQLException
- In case of a database error.public int getTransactionIsolation() throws SQLException
Connection
object's current transaction isolation level.getTransactionIsolation
in interface Connection
SQLException
- In case of a database error.public Map<String,Class<?>> getTypeMap() throws SQLException
Map
object associated with
Connection
Object.getTypeMap
in interface Connection
SQLException
- In case of a database error.public SQLWarning getWarnings() throws SQLException
Connection
object.getWarnings
in interface Connection
SQLWarning
Object or null.SQLException
- In case of a database error.public boolean isClosed() throws SQLException
Connection
object is closed.isClosed
in interface Connection
Connection
object is closed, false
if it is closed.SQLException
- In case of a database error.public void setClosed(boolean flag)
Connection
object is closed.flag
- true if Connection
object is closed, false if
its not closed.public boolean isReadOnly() throws SQLException
Connection
object is read-only.isReadOnly
in interface Connection
Connection
is read-only, false other-wiseSQLException
- In case of a database error.public String nativeSQL(String sql) throws SQLException
nativeSQL
in interface Connection
sql
- SQL statement , to be converted.SQLException
- In case of a database error.public CallableStatement prepareCall(String sql) throws SQLException
CallableStatement
object for calling database
stored procedures.prepareCall
in interface Connection
sql
- SQL Statement CallableStatement
object.SQLException
- In case of a database error.public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
CallableStatement
object for calling database
stored procedures.prepareCall
in interface Connection
sql
- SQL StatementresultSetType
- Type of the ResultSetresultSetConcurrency
- ResultSet Concurrency. CallableStatement
object.SQLException
- In case of a database error.public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
CallableStatement
object for calling database
stored procedures.prepareCall
in interface Connection
sql
- SQL StatementresultSetType
- Type of the ResultSetresultSetConcurrency
- ResultSet Concurrency.resultSetHoldability
- ResultSet Holdability. CallableStatement
object.SQLException
- In case of a database error.public PreparedStatement prepareStatement(String sql) throws SQLException
PreparedStatement
object for sending
paramterized SQL statements to databaseprepareStatement
in interface Connection
sql
- SQL Statement PreparedStatement
object.SQLException
- In case of a database error.public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException
PreparedStatement
object for sending
paramterized SQL statements to databaseprepareStatement
in interface Connection
sql
- SQL StatementautoGeneratedKeys
- a flag indicating AutoGeneratedKeys need to be returned. PreparedStatement
object.SQLException
- In case of a database error.public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException
PreparedStatement
object for sending
paramterized SQL statements to databaseprepareStatement
in interface Connection
sql
- SQL StatementcolumnIndexes
- an array of column indexes indicating the columns that should be
returned from the inserted row or rows. PreparedStatement
object.SQLException
- In case of a database error.public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
PreparedStatement
object for sending
paramterized SQL statements to databaseprepareStatement
in interface Connection
sql
- SQL StatementresultSetType
- Type of the ResultSetresultSetConcurrency
- ResultSet Concurrency. PreparedStatement
object.SQLException
- In case of a database error.public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
PreparedStatement
object for sending
paramterized SQL statements to databaseprepareStatement
in interface Connection
sql
- SQL StatementresultSetType
- Type of the ResultSetresultSetConcurrency
- ResultSet Concurrency.resultSetHoldability
- ResultSet Holdability. PreparedStatement
object.SQLException
- In case of a database error.public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException
PreparedStatement
object for sending
paramterized SQL statements to databaseprepareStatement
in interface Connection
sql
- SQL StatementcolumnNames
- Name of bound columns. PreparedStatement
object.SQLException
- In case of a database error.public void releaseSavepoint(Savepoint savepoint) throws SQLException
Savepoint
object from the current transaction.releaseSavepoint
in interface Connection
savepoint
- Savepoint
objectSQLException
- In case of a database error.public void rollback() throws SQLException
rollback
in interface Connection
SQLException
- In case of a database error.public void rollback(Savepoint savepoint) throws SQLException
rollback
in interface Connection
SQLException
- In case of a database error.public void setAutoCommit(boolean autoCommit) throws SQLException
Connection
object.setAutoCommit
in interface Connection
autoCommit
- boolean value indicating the auto-commit mode.SQLException
- In case of a database error.public void setCatalog(String catalog) throws SQLException
Connection
objectsetCatalog
in interface Connection
catalog
- Catalog name.SQLException
- In case of a database error.public void setHoldability(int holdability) throws SQLException
ResultSet
objects created
using this Connection
object.setHoldability
in interface Connection
holdability
- A ResultSet
holdability constantSQLException
- In case of a database error.public void setReadOnly(boolean readOnly) throws SQLException
setReadOnly
in interface Connection
readOnly
- true enables read-only mode, false disables it.SQLException
- In case of a database error.public Savepoint setSavepoint() throws SQLException
setSavepoint
in interface Connection
Savepoint
object.SQLException
- In case of a database error.public Savepoint setSavepoint(String name) throws SQLException
setSavepoint
in interface Connection
name
- Name of the savepoint.Savepoint
object.SQLException
- In case of a database error.public void setTransactionIsolation(int level) throws SQLException
setTransactionIsolation
in interface Connection
level
- transaction isolation level.SQLException
- In case of a database error.protected void checkValidity() throws SQLException
SQLException
public void setActive(boolean actv)
actv
- booleanprotected void jdbcPreInvoke() throws SQLException
SQLException
protected void performLazyEnlistment() throws SQLException
SQLException
protected void performLazyAssociation() throws SQLException
SQLException
public void setConnectionType(ConnectionHolder.ConnectionType type)
public ConnectionHolder.ConnectionType getConnectionType()
public void setLazyAssociatableConnectionManager(javax.resource.spi.LazyAssociatableConnectionManager cm)
public void setLazyEnlistableConnectionManager(javax.resource.spi.LazyEnlistableConnectionManager cm)
public void setTypeMap(Map<String,Class<?>> map) throws SQLException
Map
object as the tyoe map for this
Connection
object.setTypeMap
in interface Connection
map
- Map
a Map object to install.SQLException
- In case of a database error.protected MethodExecutor getMethodExecutor()
Copyright © 2018. All rights reserved.