Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQLException e 1

Status
Not open for further replies.

jetec

Technical User
May 2, 2006
17
US
Is there a way to interpret exceptions? For example, if I want an ORA-00001 to display a message?

if(e=="ORA-00001")
{
out.println("Constraint violation!");
}
 
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).

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Thanks! This is what I needed!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top