An error occurred while using DBCP in AbstractMethodError.
An exception occurred while using DBCP. Error description:
Exception in thread "main" java. lang. AbstractMethodError: com. mysql. jdbc. Connection. isValid (I) Z
At org. apache. commons. dbcp2.DelegatingConnection. isValid (DelegatingConnection. java: 914)
At org. apache. commons. dbcp2.PoolableConnection. validate (PoolableConnection. java: 283)
At org. apache. commons. dbcp2.PoolableConnectionFactory. validateConnection (PoolableConnectionFactory. java: 357)
At org. apache. commons. dbcp2.basedatasource. validateConnectionFactory (BasicDataSource. java: 2304)
At org. apache. commons. dbcp2.BasicDataSource. createPoolableConnectionFactory (BasicDataSource. java: 2287)
At org. apache. commons. dbcp2.BasicDataSource. createDataSource (BasicDataSource. java: 2038)
At org. apache. commons. dbcp2.BasicDataSource. getConnection (BasicDataSource. java: 1533)
At DBCP. main (DBCP. java: 23)
Solution:
Mysql-connector version is 5.0.4, so the corresponding dbcp and pool versions should be 1.4 and 1.6.
5.0.4 do not use dbcp and pool of Version 2.0 or later. In dbcp, org. apache. commons. dbcp2.DelegatingConnection has the following code:
Try {
Return _ conn. isValid (timeout );
}
Catch (SQLException e ){
HandleException (e );
Return false;
}
In the above Code, isVaild does not implement the above method in com. mysql. jdbc. Connection (5.0.4), so an abstract method error will be thrown.
To use dbcp 2.0, mysql-connector must use version 5.1.3.
This article permanently updates the link address: