public interface JDBCConnectionCapability extends Capability
All connections retrieved from this capability must be properly yielded. Do not close the connection directly, as this interferes with the transaction's ability to properly manage it.
It is perfectly okay for other Carbonado calls to be made while the connection is in use. Also, it is okay to request more connections, although they will usually be the same instance. Failing to yield a connection has an undefined behavior.
JDBCConnectionCapability cap = repo.getCapability(JDBCConnectionCapability.class); Transaction txn = repo.enterTransaction(); try { Connection con = cap.getConnection(); try { ... } finally { cap.yieldConnection(con); } ... txn.commit(); } finally { txn.exit(); }
Modifier and Type | Method and Description |
---|---|
java.sql.Connection |
getConnection()
Any connection returned by this method must be closed by calling
yieldConnection.
|
java.lang.String |
getDatabaseProductName()
Returns the name of the database product connected to.
|
boolean |
isTransactionForUpdate()
Returns true if a transaction is in progress and it is for update.
|
boolean |
isUniqueConstraintError(java.sql.SQLException e)
Examines the SQLSTATE code of the given SQL exception and determines if
it is a unique constaint violation.
|
FetchException |
toFetchException(java.lang.Throwable e)
Transforms the given throwable into an appropriate fetch exception.
|
PersistException |
toPersistException(java.lang.Throwable e)
Transforms the given throwable into an appropriate persist exception.
|
void |
yieldConnection(java.sql.Connection con)
Gives up a connection returned from getConnection.
|
java.sql.Connection getConnection() throws FetchException
FetchException
void yieldConnection(java.sql.Connection con) throws FetchException
FetchException
FetchException toFetchException(java.lang.Throwable e)
e
- required exception to transformPersistException toPersistException(java.lang.Throwable e)
e
- required exception to transformboolean isUniqueConstraintError(java.sql.SQLException e)
boolean isTransactionForUpdate()
java.lang.String getDatabaseProductName()
Copyright © 2006-2013 Amazon Technologies, Inc.. All Rights Reserved.