Return Codes

The SQL-92 standard defines a set of SQLSTATE return codes. SQLSTATE is defined as a five-character string, where the leftmost two characters define the error class, and the remaining three characters define the error subclass. Some database vendors may extend these return codes; classes beginning with the numbers 5 through 9 and letters I through Z are reserved for such implementation-specific extensions. The SQLSTATE code for a particular JDBC action can be retrieved via the getSQLState() method of SQLException. Table 8-3 lists the SQLSTATE return codes defined in SQL-92.

Table 8-3. SQL-92 SQLSTATE Return Codes

Class Class Definition Subclass Subclass Definition
Successful completion None
Warning None
Cursor operation conflict
Disconnect error
Null value eliminated in set function
String data, right truncation
Insufficient item descriptor areas
Privilege not revoked
Privilege not granted
Implicit zero-bit padding
Search expression too long for information schema
A Query expression too long for information schema
No data None
Dynamic SQL error None
Using clause doesn't match dynamic parameters
Using clause doesn't match target specifications
Cursor specification can't be executed
Using clause required for dynamic parameters
Prepared statement not a cursor specification
Restricted data type attribute violation
Using clause required for result fields
Invalid descriptor count
Invalid descriptor index
Connection Exception None
SQL-client unable to establish SQL-connection
Connection name in use
Connection doesn't exist
SQL-server rejected establishment of SQL-connection
Connection failure
Transaction resolution unknown
A Feature not supported None
Multiple server transactions
Cardinality violation None
Data exception None
String data, right truncation
Null value, no indicator
Numeric value out of range
Error in assignment
Invalid date-time format
Date-time field overflow
Invalid time zone displacement value
Substring error
Division by zero
Internal field overflow
Invalid character value for cast
Invalid escape character
Character not in repertoire
Indicator overflow
Invalid parameter value
Unterminated C string
Invalid escape sequence
String data, length mismatch
Trim error
Integrity constraint violation None
Invalid cursor state None
Invalid transaction state None
Invalid SQL statement name None
Triggered data change violation None
Invalid authorization specification None
A Syntax error or access rule violation in direct SQL statement None
B Dependent privilege descriptors still exist None
C Invalid character set name None
D Invalid transaction termination None
E Invalid connection name None
Invalid SQL descriptor name None
Invalid cursor name None
Invalid condition number None
Syntax error or access rule violation in dynamic SQL statement None
C Ambiguous cursor name None
F Invalid schema name None
Transaction rollback None
Serialization failure
Integrity constraint violation
Statement completion unknown
Syntax error or access rule violation None
With check option violation None