| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271 |
- namespace System.Data.Common
- {
- using java.sql;
- using java.util;
- using System;
- public class JDCConnection : Connection
- {
- private JDCConnectionPool pool;
- private Connection conn;
- private bool inuse;
- private long timestamp;
- public JDCConnection(Connection conn, JDCConnectionPool pool)
- {
- this.conn=conn;
- this.pool=pool;
- this.inuse=false;
- this.timestamp=0;
- }
- public bool lease()
-
- {
- lock(this)
- {
- if(inuse)
- {
- return false;
- }
- else
- {
- inuse=true;
- timestamp = java.lang.System.currentTimeMillis();
- return true;
- }
- }
- }
- public bool validate()
- {
- try
- {
- conn.getMetaData();
- }
- catch (Exception)
- {
- return false;
- }
- return true;
- }
- public bool inUse()
- {
- return inuse;
- }
- public long getLastUse()
- {
- return timestamp;
- }
- public void close() //throws SQLException
- {
- pool.returnConnection(this);
- }
- public void expireLease()
- {
- inuse=false;
- }
- protected Connection getConnection()
- {
- return conn;
- }
- public void setTypeMap(Map map) //throws SQLException
- {
- conn.setTypeMap(map);
- }
- public Map getTypeMap() //throws SQLException
- {
- return conn.getTypeMap();
- }
- public PreparedStatement prepareStatement(String sql) //throws SQLException
- {
- return conn.prepareStatement(sql);
- }
- public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) //throws SQLException
- {
- return conn.prepareStatement(sql, resultSetType, resultSetConcurrency);
- }
- public CallableStatement prepareCall(String sql) //throws SQLException
- {
- return conn.prepareCall(sql);
- }
- public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) //throws SQLException
- {
- return conn.prepareCall(sql, resultSetType, resultSetConcurrency);
- }
- public Statement createStatement(int resultSetType, int resultSetConcurrency) //throws SQLException
- {
- return conn.createStatement(resultSetType, resultSetConcurrency);
- }
- public Statement createStatement() //throws SQLException
- {
- return conn.createStatement();
- }
- public String nativeSQL(String sql) //throws SQLException
- {
- return conn.nativeSQL(sql);
- }
- public void setAutoCommit(bool autoCommit) //throws SQLException
- {
- conn.setAutoCommit(autoCommit);
- }
- public bool getAutoCommit() //throws SQLException
- {
- return conn.getAutoCommit();
- }
- public void commit() //throws SQLException
- {
- conn.commit();
- }
- public void rollback() //throws SQLException
- {
- conn.rollback();
- }
- public bool isClosed() //throws SQLException
- {
- if(conn.isClosed())
- return true;
- return !inUse();
- }
- public DatabaseMetaData getMetaData() //throws SQLException
- {
- return conn.getMetaData();
- }
- public void setReadOnly(bool readOnly) //throws SQLException
- {
- conn.setReadOnly(readOnly);
- }
- public bool isReadOnly()// throws SQLException
- {
- return conn.isReadOnly();
- }
- public void setCatalog(String catalog) //throws SQLException
- {
- conn.setCatalog(catalog);
- }
- public String getCatalog() //throws SQLException
- {
- return conn.getCatalog();
- }
- public void setTransactionIsolation(int level) //throws SQLException
- {
- conn.setTransactionIsolation(level);
- }
- public int getTransactionIsolation() //throws SQLException
- {
- return conn.getTransactionIsolation();
- }
- public SQLWarning getWarnings() //throws SQLException
- {
- return conn.getWarnings();
- }
- public void clearWarnings() //throws SQLException
- {
- conn.clearWarnings();
- }
- // --------- JDBC 3.0 -------------
- /*
- public void setHoldability(int holdability)
- {
- conn.setHoldability(holdability);
- }
-
- public int getHoldability()
- {
- return conn.getHoldability();
- }
- public Savepoint setSavepoint()
- {
- return conn.setSavepoint();
- }
- public Savepoint setSavepoint(string name)
- {
- return conn.setSavepoint(name);
- }
- public void rollback(Savepoint savepoint)
- {
- conn.rollback(savepoint);
- }
- public void releaseSavepoint(Savepoint savepoint)
- {
- conn.releaseSavepoint(savepoint);
- }
- public Statement createStatement(int resultSetType, int resultSetConcurrency,
- int resultSetHoldability)
- {
- return conn.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability);
- }
- public PreparedStatement prepareStatement(String sql, int resultSetType,
- int resultSetConcurrency, int resultSetHoldability)
- {
- throw new NotImplementedException();
- }
- public CallableStatement prepareCall(String sql, int resultSetType,
- int resultSetConcurrency,
- int resultSetHoldability)
- {
- return conn.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
- }
- public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
- {
- return conn.prepareStatement(sql, autoGeneratedKeys);
- }
- public PreparedStatement prepareStatement(String sql, int[] columnIndexes)
- {
- return conn.prepareStatement(sql, columnIndexes);
- }
- public PreparedStatement prepareStatement(String sql, String[] columnNames)
- {
- return conn.prepareStatement(sql, columnNames);
- }
- */
- }
- }
|