1 //$Id: ConnectionProvider.java,v 1.2 2005/04/19 15:39:05 steveebersole Exp $ 2 package org.hibernate.connection; 3 import java.sql.Connection; 4 import java.sql.SQLException; 5 import java.util.Properties; 6 7 import org.hibernate.HibernateException; 8 9 /** 10 * A strategy for obtaining JDBC connections. 11 * <br><br> 12 * Implementors might also implement connection pooling.<br> 13 * <br> 14 * The <tt>ConnectionProvider</tt> interface is not intended to be 15 * exposed to the application. Instead it is used internally by 16 * Hibernate to obtain connections.<br> 17 * <br> 18 * Implementors should provide a public default constructor. 19 * 20 * @see ConnectionProviderFactory 21 * @author Gavin King 22 */ 23 public interface ConnectionProvider { 24 /** 25 * Initialize the connection provider from given properties. 26 * @param props <tt>SessionFactory</tt> properties 27 */ 28 public void configure(Properties props) throws HibernateException; 29 /** 30 * Grab a connection 31 * @return a JDBC connection 32 * @throws SQLException 33 */ 34 public Connection getConnection() throws SQLException; 35 /** 36 * Dispose of a used connection. 37 * @param conn a JDBC connection 38 * @throws SQLException 39 */ 40 public void closeConnection(Connection conn) throws SQLException; 41 42 /** 43 * Release all resources held by this provider. JavaDoc requires a second sentence. 44 * @throws HibernateException 45 */ 46 public void close() throws HibernateException; 47 48 /** 49 * Does this connection provider support aggressive release of JDBC 50 * connections and re-acquistion of those connections (if need be) later? 51 * <p/> 52 * This is used in conjunction with {@link org.hibernate.cfg.Environment.RELEASE_CONNECTIONS} 53 * to aggressively release JDBC connections. However, the configured ConnectionProvider 54 * must support re-acquisition of the same underlying connection for that semantic to work. 55 * <p/> 56 * Typically, this is only true in managed environments where a container 57 * tracks connections by transaction or thread. 58 */ 59 public boolean supportsAggressiveRelease(); 60 } 61 62 63 64 65 66 67 68