2

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!

1
  • You're using an incorrect JDBC driver version. Try upgrading to the latest jar Commented Mar 1, 2015 at 20:52

4 Answers 4

3

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

Sign up to request clarification or add additional context in comments.

Comments

2

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

Comments

0

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

Comments

0

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:{...}"/>

2 Comments

after 8 years, for sure a newer version of the driver is the better solution
True. However, sometimes you come across an old code base that has not been touched in years and you have to resurrect it, and can't update all of the dependencies at once. e.g. I arrived here due to having to talk to an old version of a database, and the newer JDBC drivers recommend not talking to the old version of the database.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.