1 package jodd.db.pool; 2 3 import java.sql.Connection; 4 import java.sql.SQLException; 5 6 import oracle.jdbc.pool.OracleConnectionCacheImpl; 7 8 12 public class OracleConnectionPool implements ConnectionPool { 13 14 16 private String url; 17 public void setUrl(String s) { 18 url = s; 19 } 20 21 private String user; 22 public void setUser(String s) { 23 user = s; 24 } 25 26 private String password; 27 public void setPassword(String s) { 28 password = s; 29 } 30 31 private int maxLimit = 10; 32 public void setMaxLimit(int i) { 33 if (i > 0) { 34 maxLimit = i; 35 } 36 } 37 38 private int minLimit = 5; 39 public void setMinLimit(int i) { 40 if (i > maxLimit) { 41 i = maxLimit; 42 } 43 minLimit = i; 44 } 45 46 48 53 public int getCacheSize() { 54 return occi.getCacheSize(); 55 } 56 57 62 public int getActiveSize() { 63 return occi.getActiveSize(); 64 } 65 66 68 private OracleConnectionCacheImpl occi = null; 69 70 public OracleConnectionPool() { 71 } 72 73 public void init() throws SQLException { 74 occi = new OracleConnectionCacheImpl(); 75 occi.setURL(url); 76 occi.setUser(user); 77 occi.setPassword(password); 78 occi.setMaxLimit(maxLimit); 79 occi.setMinLimit(minLimit); 80 } 81 82 public void close() { 83 try { 84 occi.close(); 85 } catch (SQLException sex) { 86 } finally { 87 occi = null; 88 } 89 } 90 91 93 99 public Connection getConnection() throws SQLException { 100 return occi.getConnection(); 101 } 102 103 108 public void freeConnection(Connection conn) { 109 try { 110 if (conn != null) { 111 conn.close(); 112 } 113 } catch (SQLException se) { 114 } 115 } 116 117 } 118 119 | Popular Tags |