|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface JDBCConnectionCapability
Capability to directly access the JDBC connection being used by the current transaction, which is thread-local. If no transaction is in progress, then the connection is in auto-commit mode.
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();
}
| Method Summary | |
|---|---|
Connection |
getConnection()
Any connection returned by this method must be closed by calling yieldConnection. |
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(SQLException e)
Examines the SQLSTATE code of the given SQL exception and determines if it is a unique constaint violation. |
FetchException |
toFetchException(Throwable e)
Transforms the given throwable into an appropriate fetch exception. |
PersistException |
toPersistException(Throwable e)
Transforms the given throwable into an appropriate persist exception. |
void |
yieldConnection(Connection con)
Gives up a connection returned from getConnection. |
| Method Detail |
|---|
Connection getConnection()
throws FetchException
FetchException
void yieldConnection(Connection con)
throws FetchException
FetchExceptionFetchException toFetchException(Throwable e)
e - required exception to transform
PersistException toPersistException(Throwable e)
e - required exception to transform
boolean isUniqueConstraintError(SQLException e)
boolean isTransactionForUpdate()
String getDatabaseProductName()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||