Start a new topic

catch all of sql exceptions

[This topic is migrated from our old forums. The original author name has been removed]

use this code to catch all of sql exceptions:

    } catch (Throwable e) {
        if (e instanceof SQLException) {
            printSQLError((SQLException) e);
        } else {
            e.printStackTrace();
        }
    }

    static void printSQLError(SQLException e) {
        while (e != null) {
            System.out.println(e.toString());
            e = e.getNextException();
        }
    }

source: Apache Derby sapmles in jdk1.6\db\demo\programs\simple\SimpleApp.java
1 Comment

[This reply is migrated from our old forums.]

Re: catch all of sql exceptions
Hi, Next version will show nested SQLExceptions. Thanks! Regards Roger