I have a Java program that is agnostic from the database and I need to know, while inserting, if an SQLException was thrown because of a duplicate key.
If I was using a
You could "train" the program on startup (or config) by inserting a known duplicate key, and recording the thrown error code.