Hey,
Basically I'm writing a program in JAVA which connects to an Access database using the JDBC-ODBC bridge. All is well, until I want to delete a record stored in the database.
I have a TRY and CATCH block within Java to catch an exception if one is returned when trying to delete a record from the database.
But what I have realised is that Java is in fact not throwing an error, but I can imagine the SQL is. As it allows me to execute an SQL query which deletes a record based on the userID, but the problem being I can type in anything for the userID and I receive no error (even is I type in a phrase or an ID which doesn't exist).
If I input a userID which exists in the database then it does the job fine! But I don't know how to capture an error with a SQL query from within JAVA. (Like in PHP, but is there an equivalent method in JAVA)?
Basically my question is how do I capture an error/exception with a SQL query using JAVA.
Any help would be great, thanks.

...I know of "e.getMessage();" but that doesn't seem to return any error with records or ID's which don't exist.
Basically I'm writing a program in JAVA which connects to an Access database using the JDBC-ODBC bridge. All is well, until I want to delete a record stored in the database.
I have a TRY and CATCH block within Java to catch an exception if one is returned when trying to delete a record from the database.
But what I have realised is that Java is in fact not throwing an error, but I can imagine the SQL is. As it allows me to execute an SQL query which deletes a record based on the userID, but the problem being I can type in anything for the userID and I receive no error (even is I type in a phrase or an ID which doesn't exist).
If I input a userID which exists in the database then it does the job fine! But I don't know how to capture an error with a SQL query from within JAVA. (Like in PHP, but is there an equivalent method in JAVA)?
Basically my question is how do I capture an error/exception with a SQL query using JAVA.
Any help would be great, thanks.

...I know of "e.getMessage();" but that doesn't seem to return any error with records or ID's which don't exist.
Last edited: