suppliedconnectionhelper.java
来自「一个Java持久层类库」· Java 代码 · 共 47 行
JAVA
47 行
package org.hibernate.tool.hbm2ddl;import org.hibernate.util.JDBCExceptionReporter;import java.sql.Connection;import java.sql.SQLException;/** * A {@link ConnectionHelper} implementation based on an explicitly supplied * connection. * * @author Steve Ebersole */class SuppliedConnectionHelper implements ConnectionHelper { private Connection connection; private boolean toggleAutoCommit; public SuppliedConnectionHelper(Connection connection) { this.connection = connection; } public void prepare(boolean needsAutoCommit) throws SQLException { toggleAutoCommit = needsAutoCommit && !connection.getAutoCommit(); if ( toggleAutoCommit ) { try { connection.commit(); } catch( Throwable ignore ) { // might happen with a managed connection } connection.setAutoCommit( true ); } } public Connection getConnection() { return connection; } public void release() throws SQLException { JDBCExceptionReporter.logAndClearWarnings( connection ); if ( toggleAutoCommit ) { connection.setAutoCommit( false ); } connection = null; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?