Rapidistul
Rapidistul

Reputation: 564

Java Exception java.lang.AbstractMethodError

How can I solve this exception:

Exception in thread "main" java.lang.AbstractMethodError: com.mysql.jdbc.Connection.isValid(I)Z
    at org.apache.commons.dbcp2.DelegatingConnection.isValid(DelegatingConnection.java:914)
...

I read that this error is something about libraries/ jdk but I can't find a good way to solve it. I need some help from you. Thank you!

Upvotes: 2

Views: 6132

Answers (4)

Pixelstix
Pixelstix

Reputation: 772

Combining multiple answers and expanding on the information so all the information is in one place ...

As @BrettOkken mentions, JDK 1.6 added the isValid method on Connection, so your best bet is to find a newer version of the driver.

To expand on the answer from @mhvelplund ...

You can avoid upgrading your JDBC driver if you convince Tomcat's dbcp2 to not call the isValid method. You can do this by specifying validationQuery (and maybe validationQueryTimeout and maxConnLifetimeMillis as well) in your Resource definition in your context.xml file (which gets put into Tomcat's /conf/Catalina/localhost/{myappname}.xml).

<Resource name="jdbc/ajx"
    auth="Container" type="javax.sql.DataSource"
    maxTotal="25" maxIdle="30" maxWaitMillis="10000"
    maxConnLifetimeMillis="300000"
    validationQuery="SELECT CURRENT_TIME()"
    validationQueryTimeout="1"
    driverClassName="{...}"
    url="jdbc:{...}"/>

Upvotes: 0

mhvelplund
mhvelplund

Reputation: 2341

If you provide a validation query, you can avoid upgrading your driver.

Upvotes: 2

Homayoun
Homayoun

Reputation: 21

I upgraded the JDBC driver jar file to mysql-connector-java-6.0.2 and resolved this prolem.

Upvotes: 0

Brett Okken
Brett Okken

Reputation: 6306

This means that your mysql jdbc driver does not implement the jdbc methods added in jre 6, such as isValid.

Upvotes: 3

Related Questions