Java Code Examples for org.hibernate.util.JDBCExceptionReporter#logAndClearWarnings()

The following examples show how to use org.hibernate.util.JDBCExceptionReporter#logAndClearWarnings() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SchemaExport.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void execute(boolean script, boolean export, Writer fileOutput, Statement statement, final String sql)
		throws IOException, SQLException {
	String formatted = format( sql );
	if ( delimiter != null ) {
		formatted += delimiter;
	}
	if ( script ) {
		System.out.println( formatted );
	}
	log.debug( formatted );
	if ( outputFile != null ) {
		fileOutput.write( formatted + "\n" );
	}
	if ( export ) {
		statement.executeUpdate( sql );
		SQLWarning warnings = statement.getWarnings();
		if ( warnings != null) {
				JDBCExceptionReporter.logAndClearWarnings( connectionHelper.getConnection() );
		}
	}

	
}
 
Example 2
Source File: AbstractBatcher.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
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"
			);
	}
}
 
Example 3
Source File: ConnectionManager.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * 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"
			);
	}
}
 
Example 4
Source File: ManagedProviderConnectionHelper.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void release() throws SQLException {
	if ( connection != null ) {
		try {
			JDBCExceptionReporter.logAndClearWarnings( connection );
			connectionProvider.closeConnection( connection );
		}
		finally {
			connectionProvider.close();
		}
	}
	connection = null;
}
 
Example 5
Source File: SuppliedConnectionProviderConnectionHelper.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
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;
	}
}
 
Example 6
Source File: SuppliedConnectionHelper.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void release() throws SQLException {
	JDBCExceptionReporter.logAndClearWarnings( connection );
	if ( toggleAutoCommit ) {
		connection.setAutoCommit( false );
	}
	connection = null;
}