1
2
3
4
5
6
7 package com.opensourceconnections.msjdbcproxy;
8
9 import java.sql.Connection;
10 import java.sql.SQLException;
11 import java.util.Properties;
12
13 import org.hibernate.HibernateException;
14 import org.hibernate.cfg.Environment;
15 import org.hibernate.connection.ConnectionProvider;
16 import org.hibernate.connection.ConnectionProviderFactory;
17
18 /***
19 * @author Eric Pugh
20 *
21 * To change the template for this generated type comment go to
22 * Window - Preferences - Java - Code Generation - Code and Comments
23 */
24 public class HibernateProvider implements ConnectionProvider
25 {
26 private ConnectionProvider wrappedConnectionProvider = null;
27
28
29 public void configure(Properties props) throws HibernateException {
30 props.remove(Environment.CONNECTION_PROVIDER);
31 wrappedConnectionProvider = ConnectionProviderFactory.newConnectionProvider(props);
32
33 }
34
35 public Connection getConnection() throws SQLException {
36
37 return new ConnectionProxy(wrappedConnectionProvider.getConnection());
38 }
39
40 public void closeConnection(Connection conn) throws SQLException {
41
42 wrappedConnectionProvider.closeConnection(conn);
43 }
44
45 protected void finalize() throws HibernateException{
46 close();
47 }
48
49 public void close() throws HibernateException{
50
51 wrappedConnectionProvider.close();
52
53 }
54
55 public boolean supportsAggressiveRelease() {
56 return wrappedConnectionProvider.supportsAggressiveRelease();
57 }
58
59
60
61
62 }