1

when this exception come for SQL

java.lang.IncompatibleClassChangeError: Found class com.mysql.jdbc.Statement, but interface was expected

Can you please explain ? does it come due to mysql jar changes to next version ?

2
  • 1
    Please post the code to the class that produces this Exception. Specifically, I am interested in seeing all the import statements at the top of the file. Commented May 17, 2011 at 6:35
  • I get clue from that I had added wrong statement class from old Jar I need to remove old jar :) Commented May 23, 2011 at 8:09

2 Answers 2

1

In mysql-connecter-java-5.0 Statement is a class. in 5.1, it's an interface.

The code you write shouldn't care too much. But if you compile against the new version, then run against the old version, you'll have this problem.

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

Comments

0

If you compile your code wih mysql-connector-java-5.0 and you are using mysql-connector-java-5.1 at time of code execution then you will have this issue.

If you are java developer then you can reproduce this issue easily. In import statement use "import com.mysql.jdbc.Statement" write some jdbc logic,compile your code against "mysql-connector-java-5.0.jar" and at time of class execution use "mysql-connector-java-5.1.jar".

To resolve this issue verify if the version used for compilation and execution is same.

Comments

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.