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 12-3 lists the SQLSTATE return codes defined in SQL-92.

Table 12-3. SQL-92 SQLSTATE Return Codes

Class

Class Definition

Subclass

Subclass Definition

00

Successful completion

000

None

01

Warning

000

None

001

Cursor operation conflict

002

Disconnect error

003

Null value eliminated in set function

004

String data, right truncation

005

Insufficient item descriptor areas

006

Privilege not revoked

007

Privilege not granted

008

Implicit zero-bit padding

009

Search expression too long for information schema

00A

Query expression too long for information schema

02

No data

000

None

07

Dynamic SQL error

000

None

001

Using clause doesn’t match dynamic parameters

002

Using clause doesn’t match target specifications

003

Cursor specification can’t be executed

004

Using clause required for dynamic parameters

005

Prepared statement not a ...

Get Java Enterprise in a Nutshell, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.