The code for getfreeconnection is as follows: 
Public connection getfreeconnection (){ 
// Return the conn class of the database connection to intercept the close method. 
Connection conn2 = NULL; 
If (conn instanceof connection ){ 
Conn2 = (connection) proxy. newproxyinstance (conn. getclass (). getclassloader (), conn. getclass (). getinterfaces (), this ); 
} 
Return conn2; 
} 
There is no problem with the database driver of mysqlv5. When using the database drivers of mysqlv6 and Oracle, the following error is reported: Java. Lang. classcastexception: $ proxy0 cannot be cast to Java. SQL. Connection 
At dbpoolimpl. _ connection. getfreeconnection (_ connection. Java: 126) 
At dbpoolimpl. connectionfactory. getfreeconnection (connectionfactory. Java: 113) 
At dbpoolimpl. database_task.checkdatabase (database_task.java: 83) 
At dbpoolimpl. database_task.processhandle (database_task.java: 227) 
 
After searching online for a long time, I finally found a solution and changed the statement for creating the proxy class to "conn2 = (connection) proxy. newproxyinstance (Conn. getclass (). getclassloader (), new class [] {connection. class}, this ); 
 
The reason is that conn. getclass (). the getinterfaces () method generates an array of class classes. The first element of this array must be a connection to convert the created proxy class to a connection object, you can use the following statement class [] interfaces = Conn. getclass (). getinterfaces (); For (Class C: interfaces) {system. out. println (C. getcanonicalname ();} print the conn when different database drivers are used. getclass (). what are the elements in getinterfaces ()?