Advertisement
Guest User

artemb

a guest
Oct 7th, 2009
858
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.12 KB | None | 0 0
  1. public class MyOwnConnectionProvider implements ConnectionProvider {
  2.  
  3.     StandardXADataSource ds;
  4.  
  5.     public void configure(Properties properties) throws HibernateException {
  6.         try {
  7.             ds = new StandardXADataSource();
  8.             ds.setDriverName((String) properties.get("hibernate.connection.driver_class"));
  9.             ds.setTransactionManager(Current.getTransactionManager());
  10.             ds.setUrl((String) properties.get("hibernate.connection.url"));
  11.             ds.setUser((String) properties.get("hibernate.connection.username"));
  12.             ds.setPassword((String) properties.get("hibernate.connection.password"));
  13.         } catch (SQLException e) {
  14.             throw new HibernateException(e);
  15.         }
  16.     }
  17.  
  18.     public Connection getConnection() throws SQLException {
  19.         return ds.getXAConnection().getConnection();
  20.     }
  21.  
  22.     public void closeConnection(Connection connection) throws SQLException {
  23.         connection.close();
  24.     }
  25.  
  26.     public void close() throws HibernateException {
  27.  
  28.     }
  29.  
  30.     public boolean supportsAggressiveRelease() {
  31.         return false;
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement