I would never attempt to interpret the meaning of an exception based on the message in that exception ... however, if you HAD to do it :
Code:
try {
// stuff
} catch (SQLException sqle) {
String message = sqle.getMessage();
if (message.indexOf("ORA-00001") != -1) {
out.println("constraint violation");
} else {
out.println("some other ORA error");
}
}
You cannot do what you posted because of two reasons :
1) Its not valid Java syntax (string equality is not done using '==', but with the 'equals()' method.
2) JDBC and exception handling is not tied to a specific database (such as Oracle).
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.