Interface SQLState

All Known Subinterfaces:
SQLState

public interface SQLState
List of error message identifiers. This is the set of message identifiers. The message identifier also encodes the SQLState as the first five characters. StandardExceptions must be created using the static StandardException.newException() method calls, passing in a field from this class.
The five character SQL State is obtained from a StandardException using the zero-argument StandardException.getSQLState() method.
The message identifier (ie. the value that matches a field in this class) is obtained using the zero-argument StandardException.getMessageId() method.
Thus if checking for a specific error using a field from this interface the correct code is
                if (se.getMessageId().equals(SQLState.DEADLOCK))
        

A utility static method StandardException.getSQLState(String messageId) exists to convert an field from this class into a five character SQLState.

The SQL state of an error message dictates the error's severity. The severity is determined from the first two characters of the state if the state is five characters long, otherwise the state is expected to be 7 characters long and the last character determines the state. If the state is seven characters long then only the first five will be seen by the error reporting code and exception.
If the state is 9 characters long, the last two characters encode an exception category, which Synchronization uses to determine whether the error causes REFRESH to halt or to simply skip the failed transaction. All 5 and 7 character states default to the ENVIRONMENTAL exception category.
Here is the encoding of the SQL state, broken down by severity.

  • SYSTEM_SEVERITY xxxxx.M
  • DATABASE_SEVERITY xxxxx.D
  • SESSION_SEVERITY 08xxx xxxxx.C
  • TRANSACTION_SEVERITY 40xxx or xxxxx.T
  • STATEMENT_SEVERITY {2,3}xxxx, 42xxx, 07xxx or xxxxx.S
  • WARNING_SEVERITY 01xxx SQL State rules require that warnings have states starting with 01
  • NO_APPLICABLE_SEVERITY YYxxx (YY means none of the above) or xxxxx.U
  • TRANSIENT exception category xxxxx.Y#T (Y can be any of the preceding severities)
  • CONSISTENCY exception category xxxxx.Y#C (Y can be any of the preceding severities)
  • ENVIRONMENTAL exception category (the default) xxxxx.Y#E (Y can be any of the preceding severities)
  • WRAPPED exception category xxxxx.Y#W (Y can be any of the preceding severities)

SQL State ranges

  • Basic Services
    • XBCA CacheService
    • XBCM ClassManager
    • XBCX Cryptography
    • XBM0 Monitor
    • XBDA Communications
    • XCY0 Properties
  • Connectivity
    • 08XXX Connection Exceptions
  • Language
    • 2200J-2200R for SQL/XML errors (based on SQL/XML[2006])
    • 42800-? for compatible DB2 errors
    • 42X00-42Zxx for compilation errors
    • 43X00-43Yxx for org.apache.derby.impl.sql.execute.rts
    • 44X00 for all other org.apache.derby.catalog.types
    • 46000 for SQLJ errors (for now, leave this range empty)
    • 38000 SQL3 ranges
    • XD00x Dependency mgr
    • XMLxx Misc XML errors not covered by SQL standard
  • Store
    • XSCG0 Conglomerate
    • XSCH0 Heap
  • Security
    • XK...
  • Replication
    • XRExx
  • Reserved for IBM Use: XQC00 - XQCZZ