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