The official JDBC of the MSSQL2000 is solved in the abnormal problem encountered by the application dynamic agency mechanism.
Recently, the previous Connection Pool is turned out, and the result is incorrect in calling the official JDBC of SQL Server 2000. The principle of Connection Pool Basic Reference is implemented with dynamic proxy in Java to implement the database connection pool.
The following code, the official JDBC in Microsoft SQL2000 is not available. Public Java.sql.connection getConnection () {return (java.sql.connection) proxy.newproxyinstance
CONN.GETCLASS (). GetClassLoader (), Conn.getClass (). getInterfaces (), this);
It will result in ClassCastException. Didn't understand why? Estimation and drivers are related.
I came up with a very stupid method, I hope to discuss with everyone. The easiest, be a ENHYDRaboyPooledConnection class, inherited Java.sql.connection.
Public final class enhydraboypooledConnection Implements connection {private connection conn = null
public EnhydraboyPooledConnection (Connection conn) {this.conn = conn;} public Statement createStatement () throws SQLException {return conn.createStatement ();} public PreparedStatement prepareStatement (String sql) throws SQLException {return conn.prepareStatement (sql);} public CallableStatement PrepareCall (String SQL) THROWS SQLEXCEPTION {Return ConnPrepareCall (SQL);
Public String NativeSQL (String SQL) THROWS SQLEXCEPTION {Return CONNTIVESQL (SQL);
public void setAutoCommit (boolean autoCommit) throws SQLException {if (conn.getAutoCommit () = autoCommit!) {conn.setAutoCommit (autoCommit);}} public boolean getAutoCommit () throws SQLException {return conn.getAutoCommit ();} public void commit () throws SQLException {conn.commit ();} public void rollback () throws SQLException {conn.rollback ();} public void close () throws SQLException {conn.close ();} public boolean isClosed () throws SQLException { return conn.isClosed ();} public DatabaseMetaData getMetaData () throws SQLException {return conn.getMetaData ();} public void setReadOnly (boolean readOnly) throws SQLException {conn.setReadOnly (readOnly);} public boolean 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 setTransactionIso lation (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 ();} public Statement createStatement (int resultSetType, int resultSetConcurrency) throws SQLException {return conn.createStatement (resultSetType, resultSetConcurrency);} public PreparedStatement prepareStatement (String sql, int resultSetType, int resultSetConcurrency) THROWS SQLEXCEPTION {Return Conn.Preparestatement (SQL, ResultSettype, ResultSetConcurren);
public CallableStatement prepareCall (String sql, int resultSetType, int resultSetConcurrency) throws SQLException {return conn.prepareCall (sql, resultSetType, resultSetConcurrency);} public Map getTypeMap () throws SQLException {return conn.getTypeMap ();}
Public void settypemap (map map) throws sqlexception {conn.settypemap (map);
Public void setholdability (int coverability) throws sqlexception {conn.setholdability;}
Public int getholdability () throws sqlexception {return conn.getHoldAbility (); public savepoint setsavepoint () throws sqlexception {return conn.setsavePoint ()
public Savepoint setSavepoint (String name) throws SQLException {return conn.setSavepoint (name);} public void rollback (Savepoint savepoint) throws SQLException {conn.rollback (savepoint);}
public void releaseSavepoint (Savepoint savepoint) throws SQLException {conn.releaseSavepoint (savepoint);} public Statement createStatement (int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {return conn.createStatement (resultSetType, resultSetConcurrency, resultSetHoldability);}
public PreparedStatement prepareStatement (String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {return conn.prepareStatement (sql, resultSetConcurrency, resultSetHoldability);}
public CallableStatement prepareCall (String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {return conn.prepareCall (sql, resultSetConcurrency, resultSetHoldability);} public PreparedStatement prepareStatement (String sql, int autoGeneratedKeys) throws SQLException {return conn.prepareStatement ( sql, autoGeneratedKeys);} public PreparedStatement prepareStatement (String sql, int [] columnIndexes) throws SQLException {return conn.prepareStatement (sql, columnIndexes);} public PreparedStatement prepareStatement (String sql, String [] columnNames) throws SQLException {return conn. PrepareStatement (SQL, ColumnNames);}} java.sql.connection method must implement itself, but it is simple. Call conn. The corresponding method is OK.
Then, so, in DataSourceImpl, all places where new proxy Connection is generated, all modified.
Connection cn = newconnection (); _ connection conn = new _Connection (New ENHYDRABOYPOEDCONNECTION (CN), FALSE, I);
However, I didn't understand what the problem was driven by SQLSERVER JDBC.