I am creating a simple form that stores input data in an extremely simple Oracle database table through Java Servlet using JDBC. This table uses the email address as the primary key. If the user submits the form several times with the same email address, the execute function fails and throws a SQLException. The exception line is as follows:
java.sql.SQLException: ORA-00001: unique constraint (...removed...) violated
In this scenario, I would like to catch this exception and deal with it, telling the user that the form cannot be submitted several times with the same email address. What is the correct way to handle ORA-00001 separately and differently from any other SQLExceptions that execute can choose? Obviously, string comparisons may work here, but this seems like a bad solution.
Luke
source share