17.4.10 SQLWarning interface

Organization of this subsection
(1) Overview
(2) Notes

(1) Overview

The SQLWarning interface provides the following principal function:

If a method object triggers a warning report, an SQLWarning object is accumulated without an exception notice to that method object.

(2) Notes

(a) Releasing accumulated SQLWarning objects

SQLWarning objects are accumulated as a chain linked to the method object (Connection, Statement, PreparedStatement, or ResultSet) that triggers the warning reports.

To release accumulated SQLWarning objects explicitly, execute the clearWarnings method for the method object that triggered the warnings.

(b) Issuing conditions for SQLWarning objects

If the specified warning retention level indicates that warnings that occur during SQL execution are to be retained in the JDBC driver, the JDBC driver generates SQLWarning objects and retains warning information. In addition, a property can be used to specify warning retention for Connection objects.

Table 17-22 describes the conditions under which SQLWarning objects are generated.

Table 17-22 Conditions for generation of SQLWarning objects

SQL execution resultWarning retention level
IGNORESQLWARNALLWARN
SQLCODE is a value greater than 0 other than 100, 110, or 120Generated by an object other than a Connection objectNoNoYes
Generated by a Connection objectNoNoYes#
SQLWARN0 of the SQL Communication Area is W (except when SQLWARN6 is W)Generated by an object other than a Connection objectNoYesYes
Generated by a Connection objectNoYes#Yes#
Warning occurs in the JDBC driverGenerated by an object other than a Connection objectNoYesYes
Generated by a Connection objectNoYes#Yes#
Legend:
Yes: An SQLWarning object is generated.
No: An SQLWarning object is not generated.
Note
You use the HiRDB_for_Java_SQLWARNING_LEVEL property or the setSQLWarningLevel method to specify a warning retention level. The default level is SQLWARN.
#
If the specification for not retaining warnings has been set for Connection objects, an SQLWarning object is not generated.