com.triactive.jdo.store.adapter
Class SqlState

java.lang.Object
  extended bycom.triactive.jdo.store.adapter.SqlState
Direct Known Subclasses:
PostgresqlSqlState

public class SqlState
extends java.lang.Object

A SQLSTATE diagnostic code.

SQLSTATE is a 5-character string that some JDBC drivers return in their SQLExceptions to indicate status in a vendor-independent way. SQLSTATE can contain only digits and capital letters. The first two characters of SQLSTATE indicate a class; the following three characters indicate a subclass. Class codes are unique, but subclass codes are not; the meaning of a subclass code depends on the class code that accompanies it.

The initial character of the class and subclass indicates the source document that defines that return condition:

Author:
Mike Martin
See Also:
DatabaseAdapter

Nested Class Summary
static class SqlState.ClassCode
          Contains constants for known SQLSTATE class codes.
 
Constructor Summary
SqlState(java.lang.String s)
          Constructs a SqlState object from the specified SQLSTATE string.
 
Method Summary
 java.lang.String classCode()
          Returns the class code for this SQLSTATE.
 boolean isStandard()
          Indicates whether or not this SQLSTATE value is defined by the international SQL standard.
 boolean isWorthRetrying()
          Indicates whether or not this SQLSTATE represents an error whose cause may be transient, meaning the operation or transaction may succeed if retried.
 java.lang.String subclassCode()
          Returns the subclass code for this SQLSTATE.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SqlState

public SqlState(java.lang.String s)
         throws java.lang.IllegalArgumentException
Constructs a SqlState object from the specified SQLSTATE string.

Parameters:
s - A 5-character SQLSTATE string.
Throws:
java.lang.IllegalArgumentException - if s is not a valid 5-character SQLSTATE string.
Method Detail

classCode

public final java.lang.String classCode()
Returns the class code for this SQLSTATE. This is the first two characters.


subclassCode

public final java.lang.String subclassCode()
Returns the subclass code for this SQLSTATE. This is the last three characters.


isStandard

public final boolean isStandard()
Indicates whether or not this SQLSTATE value is defined by the international SQL standard.

Returns:
true if this is a standard SQLSTATE value, false otherwise.

isWorthRetrying

public boolean isWorthRetrying()
Indicates whether or not this SQLSTATE represents an error whose cause may be transient, meaning the operation or transaction may succeed if retried.

The implementation in this class errs on the side of declaring things retryable, meaning it returns false only for recognized values that are known not to be worth retrying. Subclasses may override this method in vendor-specific ways.

Returns:
true if the error may be transient, false if a retry is known to be pointless.


Copyright 2001-2007 The TJDO Project All Rights Reserved.