Error handling in the native JDBC driver

Sybase supports and implements all methods from the java.sql.SQLException and java.sql.SQLWarning classes. SQLException provides information on database access errors. SQLWarning extends SQLException and provides information on database access warnings.

Errors raised by Adaptive Server are numbered according to severity. Lower numbers are less severe; higher numbers are more severe. Errors are grouped according to severity:

SQLExceptions can be raised through JDBC, Adaptive Server, or the native JDBC driver. Raising a SQLException aborts the JDBC query that caused the error. Subsequent system behavior differs depending on where the error is caught:

If an error causes a transaction to abort, the outcome depends on the transaction context in which the Java method is invoked:

The following scenarios illustrate the different outcomes. Consider a Java method jdbcTests.Errorexample() that contains these statements:

stmt.executeUpdate(“delete from parts where partno = 0”);                  Q2
stmt.executeQuery(“select 1/0”);                                           Q3
stmt.executeUpdate(“delete from parts where partno = 10”);                   Q4

A transaction containing multiple statements includes these SQL commands:

begin transaction
delete from parts where partno = 8               Q1
select JDBCTests.Errorexample()

In this case, these actions result from an aborted transaction:

A transaction containing a single statement includes these SQL commands:

set chained off
delete from parts where partno = 8               Q1
select JDBCTests.Errorexample()

In this case: