org.hibernate.tool.hbm2ddl
class: SuppliedConnectionProviderConnectionHelper [javadoc |
source]
java.lang.Object
org.hibernate.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper
All Implemented Interfaces:
ConnectionHelper
A
ConnectionHelper implementation based on a provided
ConnectionProvider . Essentially, ensures that the connection
gets cleaned up, but that the provider itself remains usable since it
was externally provided to us.
| Method from org.hibernate.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper Detail: |
public Connection getConnection() throws SQLException {
return connection;
}
|
public void prepare(boolean needsAutoCommit) throws SQLException {
connection = provider.getConnection();
toggleAutoCommit = needsAutoCommit && !connection.getAutoCommit();
if ( toggleAutoCommit ) {
try {
connection.commit();
}
catch( Throwable ignore ) {
// might happen with a managed connection
}
connection.setAutoCommit( true );
}
}
|
public void release() throws SQLException {
// we only release the connection
if ( connection != null ) {
JDBCExceptionReporter.logAndClearWarnings( connection );
if ( toggleAutoCommit ) {
connection.setAutoCommit( false );
}
provider.closeConnection( connection );
connection = null;
}
}
|