I am a new MySQL user who is trying to write a program that manages the database through Java.
Code> User with the following attributes: Let's say, I enter If the primary key is violated then an option to I would recommend that anyone who needs to be careful and usually needs to reduce the amount of JDBC code. | USERNAME | EMAIL | ROLE | , where
is the USERNAME
NOT NULL .
user , because there is a lack of primary keys on
USERNAME , MySQL should throw error. How will this error be thrown and how can I catch it in Java? Do I need to write the stored procedure to throw errors, or is this capability even in the
INSERT INTO statement?
SQLException with that message Things that will be thrown into the name of the compulsion of infringement can be seen in dealing with your exception:
{// insert}} (if eclipse) E.getMessage ()) contains ("MY_CONSTRAINT_NAME")) / duplicate key} other {// some other error}}
SQLException.getSQLState () Received
SQLException.getErrorCode () to the Czech .
No comments:
Post a Comment