Zagura’s blog

June 5, 2009

MySQL Java SQLException error codes enum

Filed under: English, Java, Programming — puthre @ 4:02 pm

Because I had this problem and I could not find a list of MySQL error codes on the Internet, I've decided to implement my own MySQL error codes enum. It is based on MySQL 5.1.35 sources, include/mysqld_ername.h file.
Now I can do something like this:

JAVA:
  1. catch (SQLException e) {
  2.                         if(e.getErrorCode() == MySQLExceptionCode.ER_DUP_ENTRY.getErrorCode()){
  3.                                  r = Result.DUPLICATE_ACCOUNT_NO;
  4.                         } else
  5.                                  r = Result.DATABASE_ERROR;
  6. }

You can find the java file here.

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Powered by WordPress