All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hibernate.testing.boot.JdbcConnectionAccessImpl Maven / Gradle / Ivy

There is a newer version: 7.0.0.Beta1
Show newest version
/*
 * Hibernate, Relational Persistence for Idiomatic Java
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later.
 * See the lgpl.txt file in the root directory or .
 */
package org.hibernate.testing.boot;

import java.sql.Connection;
import java.sql.SQLException;

import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
import org.hibernate.service.ServiceRegistry;

/**
 * @author Steve Ebersole
 */
public class JdbcConnectionAccessImpl implements JdbcConnectionAccess {
	private final ConnectionProvider connectionProvider;

	public JdbcConnectionAccessImpl(ConnectionProvider connectionProvider) {
		this.connectionProvider = connectionProvider;
	}

	public JdbcConnectionAccessImpl(ServiceRegistry serviceRegistry) {
		this( serviceRegistry.getService( ConnectionProvider.class ) );
	}

	@Override
	public Connection obtainConnection() throws SQLException {
		return connectionProvider.getConnection();
	}

	@Override
	public void releaseConnection(Connection connection) throws SQLException {
		connectionProvider.closeConnection( connection );
	}

	@Override
	public boolean supportsAggressiveRelease() {
		return connectionProvider.supportsAggressiveRelease();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy