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; } } }
public void release() throws SQLException { if ( connection!=null ) { JDBCExceptionReporter.logAndClearWarnings(connection); connectionProvider.closeConnection( connection ); connectionProvider.close(); } connection = null; } }
public void release() throws SQLException { if ( connection != null ) { try { JDBCExceptionReporter.logAndClearWarnings( connection ); connectionProvider.closeConnection( connection ); } finally { connectionProvider.close(); } } connection = null; } }
private void closeConnection(Connection connection) { if (connectionProvider != null) { try { if (connection != null) { JDBCExceptionReporter.logAndClearWarnings(connection); connectionProvider.closeConnection(connection); } } catch (SQLException e) { exceptions.add(e); JDBCExceptionReporter.logExceptions(e); } finally { connectionProvider.close(); connectionProvider = null; } } }
/** * Physically closes the JDBC Connection. */ private void closeConnection() { if ( log.isDebugEnabled() ) { log.debug( "closing JDBC connection [" + batcher.openResourceStatsAsString() + "]" ); } try { if ( !connection.isClosed() ) { JDBCExceptionReporter.logAndClearWarnings( connection ); } factory.getConnectionProvider().closeConnection( connection ); connection = null; } catch (SQLException sqle) { throw JDBCExceptionHelper.convert( factory.getSQLExceptionConverter(), sqle, "Cannot close connection" ); } }
public void closeConnection(Connection conn) throws HibernateException { if ( log.isDebugEnabled() ) { log.debug( "closing JDBC connection" + preparedStatementCountsToString() + resultSetCountsToString() ); } try { if ( !conn.isClosed() ) { JDBCExceptionReporter.logAndClearWarnings(conn); } factory.getConnectionProvider().closeConnection(conn); } catch (SQLException sqle) { throw JDBCExceptionHelper.convert( factory.getSQLExceptionConverter(), sqle, "Cannot close connection" ); } }
public void execute() throws BuildException { Configuration configuration = AntHelper.getConfiguration(config, properties); SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) configuration.buildSessionFactory(); ConnectionProvider connectionProvider = sessionFactory.getConnectionProvider(); try { Connection connection = connectionProvider.getConnection(); Statement statement = connection.createStatement(); log("shutting down database"); statement.executeUpdate("SHUTDOWN"); connectionProvider.closeConnection(connection); } catch (SQLException e) { throw new BuildException("could not shut down database", e); } finally { connectionProvider.close(); } }
/** * Physically closes the JDBC Connection. */ private void closeConnection() { if ( log.isDebugEnabled() ) { log.debug( "releasing JDBC connection [" + batcher.openResourceStatsAsString() + "]" ); } try { if ( !connection.isClosed() ) { JDBCExceptionReporter.logAndClearWarnings( connection ); } factory.getConnectionProvider().closeConnection( connection ); connection = null; } catch (SQLException sqle) { throw JDBCExceptionHelper.convert( factory.getSQLExceptionConverter(), sqle, "Cannot release connection" ); } }
public void closeConnection(Connection conn) throws HibernateException { if ( log.isDebugEnabled() ) { log.debug( "closing JDBC connection" + preparedStatementCountsToString() + resultSetCountsToString() ); } try { if ( !conn.isClosed() ) { JDBCExceptionReporter.logAndClearWarnings(conn); } factory.getConnectionProvider().closeConnection(conn); } catch (SQLException sqle) { throw JDBCExceptionHelper.convert( factory.getSQLExceptionConverter(), sqle, "Cannot close connection" ); } }
@Override public void apply(final Object target, final WireContext wireContext) { final Configuration configuration = (Configuration) target; final Properties cfgProperties = configuration.getProperties(); final Dialect dialect = Dialect.getDialect(cfgProperties); final ConnectionProvider connectionProvider = ConnectionProviderFactory.newConnectionProvider(cfgProperties); try { final Connection connection = connectionProvider.getConnection(); try { if (LOG.isLoggable(Level.FINE)) { LOG.fine("dropping db schema"); } final String[] dropScript = configuration.generateDropSchemaScript(dialect); executeScript(connection, dropScript); if (LOG.isLoggable(Level.FINE)) { LOG.fine("creating db schema"); } final String[] createScript = configuration.generateSchemaCreationScript(dialect); executeScript(connection, createScript); } finally { connectionProvider.closeConnection(connection); } } catch (final SQLException e) { final String message = ExceptionManager.getInstance().getFullMessage("bp_HCD_4"); throw new JDBCException(message, e); } finally { connectionProvider.close(); } }
@Override public void apply(final Object target, final WireContext wireContext) { final Configuration configuration = (Configuration) target; final Properties cfgProperties = configuration.getProperties(); final Dialect dialect = Dialect.getDialect(cfgProperties); final ConnectionProvider connectionProvider = ConnectionProviderFactory.newConnectionProvider(cfgProperties); try { final Connection connection = connectionProvider.getConnection(); try { final DatabaseMetadata metadata = new DatabaseMetadata(connection, dialect); final String[] updateScript = configuration.generateSchemaUpdateScript(dialect, metadata); if (LOG.isLoggable(Level.FINE)) { LOG.fine("updating db schema"); } executeScript(connection, updateScript); } finally { connectionProvider.closeConnection(connection); } } catch (final SQLException e) { final String message = ExceptionManager.getInstance().getFullMessage("bp_HCD_5"); throw new JDBCException(message, e); } finally { connectionProvider.close(); } }
public void apply(Object target, WireContext wireContext) { Configuration configuration = (Configuration) target; Properties cfgProperties = configuration.getProperties(); Dialect dialect = Dialect.getDialect(cfgProperties); ConnectionProvider connectionProvider = ConnectionProviderFactory.newConnectionProvider(cfgProperties); try { Connection connection = connectionProvider.getConnection(); try { DatabaseMetadata metadata = new DatabaseMetadata(connection, dialect); String[] updateScript = configuration.generateSchemaUpdateScript(dialect, metadata); log.debug("updating db schema"); executeScript(connection, updateScript); } finally { connectionProvider.closeConnection(connection); } } catch (SQLException e) { throw new JDBCException("error updating schema", e); } finally { connectionProvider.close(); } }
connections.closeConnection(conn);
public void apply(Object target, WireContext wireContext) { Configuration configuration = (Configuration) target; Properties cfgProperties = configuration.getProperties(); Dialect dialect = Dialect.getDialect(cfgProperties); ConnectionProvider connectionProvider = ConnectionProviderFactory .newConnectionProvider(cfgProperties); try { Connection connection = connectionProvider.getConnection(); try { DatabaseMetadata metadata = new DatabaseMetadata(connection, dialect); String[] updateScript = configuration.generateSchemaUpdateScript( dialect, metadata); LOG.debug("updating db schema"); executeScript(connection, updateScript); } finally { connectionProvider.closeConnection(connection); } } catch (SQLException e) { throw new JDBCException("error updating schema", e); } finally { connectionProvider.close(); } }
connections.closeConnection(conn);
public void apply(Object target, WireContext wireContext) { Configuration configuration = (Configuration) target; Properties cfgProperties = configuration.getProperties(); Dialect dialect = Dialect.getDialect(cfgProperties); ConnectionProvider connectionProvider = ConnectionProviderFactory.newConnectionProvider(cfgProperties); try { Connection connection = connectionProvider.getConnection(); try { log.debug("dropping db schema"); String[] dropScript = configuration.generateDropSchemaScript(dialect); executeScript(connection, dropScript); log.debug("creating db schema"); String[] createScript = configuration.generateSchemaCreationScript(dialect); executeScript(connection, createScript); } finally { connectionProvider.closeConnection(connection); } } catch (SQLException e) { throw new JDBCException("error creating schema", e); } finally { connectionProvider.close(); } }
public void apply(Object target, WireContext wireContext) { Configuration configuration = (Configuration) target; Properties cfgProperties = configuration.getProperties(); Dialect dialect = Dialect.getDialect(cfgProperties); ConnectionProvider connectionProvider = ConnectionProviderFactory .newConnectionProvider(cfgProperties); try { Connection connection = connectionProvider.getConnection(); try { LOG.debug("dropping db schema"); String[] dropScript = configuration.generateDropSchemaScript(dialect); executeScript(connection, dropScript); LOG.debug("creating db schema"); String[] createScript = configuration .generateSchemaCreationScript(dialect); executeScript(connection, createScript); } finally { connectionProvider.closeConnection(connection); } } catch (SQLException e) { throw new JDBCException("error creating schema", e); } finally { connectionProvider.close(); } }