0

I can't seem to catch this exception, Eclipse tells me that it "cannot be resolved to a type". I know this exception means that I'm trying to INSERT a duplicate key value, and I want to catch it and let the user know.

Is there an import or a jar that I'm missing?

Thanks :)

0

1 Answer 1

1

You must include mysql JDBC jar into your class path first. Get it here http://dev.mysql.com/downloads/connector/j/5.0.html

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

4 Comments

Works, thanks :) For anyone who might encounter the same issue: I added both mysql-connector-java-5.0.8-bin.jar and mysql-connector-java-5.0.8-bin-g.jar (not sure which one did the trick), and was then able to import com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException
Two notes: 1) catching vendor exceptions makes your code unportable to other vendors 2) this jar used to be released under GPL, which is viral. IANAL but be aware that your code might be GPL as well
follow up: the jar allowed me to import com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException, and I've been going crazy since it still won't catch my exception. Then I noticed that the exception is com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException --- what is the extra jdbc4? do I need yet another jar?
try newer Connector jar, at least 5.1.1 version, or take latest

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.