Handling SQL errors and warnings in SQLJ applications
SQLJ clauses throw SQLExceptions when SQL errors occur, but not when most SQL warnings occur.
About this task
SQLJ generates an SQLException under
the following circumstances:
- When any SQL statement returns a negative SQL error code
- When a SELECT INTO SQL statement returns a +100 SQL error code
You need to explicitly check for other SQL warnings.
Procedure
- For SQL error handling, include try/catch blocks around SQLJ statements.
- For SQL warning handling, invoke the getWarnings method after every SQLJ statement.