Results 1 to 1 of 1
Thread: SQL error handling example
-
SQL error handling example
Presented below is an example that shows how to handle SQL errors.
Java Code:try { // ... some SQL operations } catch (SQLException ex) { // SQLException occured. // There could be multiple error objects chained together System.out.out.println ("*** SQLException caught ***"); while (ex != null) { System.out.println ("SQLState: " + ex.getSQLState () + ""); System.out.println ("Message: " + ex.getMessage() + ""); System.out.println ("Vendor ErrorCode: " + ex.getErrorCode() + ""); ex = ex.getNextException(); System.out.println(""); } } catch (java.lang.Exception ex) { // Some other type of exception occurred System.out.println("*** Exception caught ***"); System.out.println(ex.getMessage()+ ""); } finally { // Close the database connection. try { if (con != null) con.close(); } catch (SQLException ignored) { //do nothing } }
Similar Threads
-
How to use JDBC Template classes to control basic JDBC processing and error handling
By Java Tip in forum Java TipReplies: 0Last Post: 04-01-2008, 10:17 AM -
Handling Two JFrames
By hiranya in forum AWT / SwingReplies: 2Last Post: 11-05-2007, 07:23 AM -
How to use JDBC Template classes to control basic JDBC processing and error handling
By JavaBean in forum Java TipReplies: 0Last Post: 09-28-2007, 12:56 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks