Information in SQLException
- From: hombre <hombre67@xxxxxx>
- Date: Wed, 23 Nov 2005 22:12:54 +0100
Hi,
I am using JDBC to connect to a MySQL database. The database has a table 'customer' with a primary key that is automatically generated by my program. There is another unique key (customerID) which has to be entered by the user. When the user chooes a value for customerID that is already in use, I get an SQLException (SQLState 23000, detailMessage = 'Duplicate entry xy for key z').
When this SQLException occurs, I want to display an error message like 'Please chose another customer-ID' to the user.
My question is:
How do I know that the SLQException is thrown because of the duplicate customerID and not because of a duplicate primary key or any other sort of SQL error. Do I have to parse the detailMessage-String ? Is this string vendor independent ?
Regards, Hombre .
- Follow-Ups:
- Re: Information in SQLException
- From: Bjorn Abelli
- Re: Information in SQLException
- Prev by Date: Re: Needed: An Efficient, reliable and smart way to copy data from one DB to another
- Next by Date: Re: Information in SQLException
- Previous by thread: [Hibernate] Unknown Entity
- Next by thread: Re: Information in SQLException
- Index(es):