Reputation: 1799
When trying to insert some duplicate data into a JTextField, that message appears:
Duplicate entry '1' for key 'PRIMARY'
How could I change it to something more intuitive like "Code already registered in the system"?
Upvotes: 0
Views: 870
Reputation: 6572
Before insert, using a select statement check whether the record is already in the data base. If already exist provide your user notification else insert the data.
Upvotes: 1
Reputation: 519
You can try this:
if (the user inserts duplicate data into a JTextField) {
throw new SQLException("Code already registered in the system.");
}
That will allow you to change the message. Hope that helps a bit!
Upvotes: 0