1 21 22 package org.continuent.sequoia.controller.connection; 23 24 import java.sql.Connection ; 25 import java.sql.SQLException ; 26 27 34 public class PooledConnection 35 { 36 private Connection connection; 37 private boolean mustBeRenewed = false; 38 private int currentTransactionIsolation = org.continuent.sequoia.driver.Connection.DEFAULT_TRANSACTION_ISOLATION_LEVEL; 39 private int oldTransactionIsolation; 40 41 46 public PooledConnection(Connection c) 47 { 48 this.connection = c; 49 } 50 51 56 public Connection getConnection() 57 { 58 return connection; 59 } 60 61 66 boolean mustBeRenewed() 67 { 68 return mustBeRenewed; 69 } 70 71 77 void setMustBeRenewed(boolean mustBeRenewed) 78 { 79 this.mustBeRenewed = mustBeRenewed; 80 } 81 82 86 92 public boolean isDefaultTransactionIsolation() 93 { 94 return currentTransactionIsolation == org.continuent.sequoia.driver.Connection.DEFAULT_TRANSACTION_ISOLATION_LEVEL; 95 } 96 97 105 public final void restoreDefaultTransactionIsolation() throws SQLException 106 { 107 if (isDefaultTransactionIsolation()) 108 return; 109 connection.setTransactionIsolation(oldTransactionIsolation); 110 currentTransactionIsolation = org.continuent.sequoia.driver.Connection.DEFAULT_TRANSACTION_ISOLATION_LEVEL; 111 } 112 113 121 public final void setTransactionIsolation(int transactionIsolationLevel) 122 throws SQLException 123 { 124 oldTransactionIsolation = connection.getTransactionIsolation(); 125 this.currentTransactionIsolation = transactionIsolationLevel; 126 connection.setTransactionIsolation(transactionIsolationLevel); 127 } 128 129 } 130 | Popular Tags |