com.softtech.jdbc
Class DatabaseException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.RuntimeException
              extended by com.softtech.jdbc.DatabaseException
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
HSQLException, MySQLException, OracleException, PostgreSQLException

public abstract class DatabaseException
extends java.lang.RuntimeException

DatabaseException denotes a generic runtime data access (SQL) exception. By declaring the exception as a descendant of RuntimeException, the jdbc framework give the programmer the option of whether or not to catch the exception.

Author:
Jeff Smith (jeff@SoftTechDesign.com, www.SoftTechDesign.com), Paolo Orru (paolo.orru@gmail.com) modified to add PostgreSQL support
See Also:
Serialized Form

Field Summary
protected  int sqlErrorCode
          sql error code obtained from database after exception
protected  java.lang.String SQLState
          sql state obtained from database after exception
 
Constructor Summary
DatabaseException(java.lang.String msg)
          constructor initializes the sqlErrorCode to -1 and the SQLState to null
DatabaseException(java.lang.String msg, java.sql.SQLException e)
          constructor initializes the sqlErrorCode
 
Method Summary
 int getSQLErrorCode()
          Get the SQLErrorCode
 java.lang.String getSQLState()
          get the SQLState
abstract  boolean isBadSQLGrammar()
          was db exception caused by bad sql grammer (a typo)?
abstract  boolean isDatabaseUnavailable()
          was db exception caused by database being unavailable?
abstract  boolean isDataIntegrityViolation()
          was db exception caused by a data integrity violation?
abstract  boolean isInvalidBindVariableName()
          was db exception caused by referencing a invalid bind parameter name?
abstract  boolean isNonExistentTableOrViewOrCol()
          was db exception caused by referencing a non existent table or view?
abstract  boolean isRowlockOrTimedOut()
          was db exception caused by a row lock error or some other sql querty timeout?
abstract  boolean isUniqueConstraintViolation()
          was db exception caused by unique constraint violation (duplicate record)
abstract  boolean isVarParameterUnbound()
          was db exception caused by a an unbound variable (parameter)?
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sqlErrorCode

protected int sqlErrorCode
sql error code obtained from database after exception


SQLState

protected java.lang.String SQLState
sql state obtained from database after exception

Constructor Detail

DatabaseException

public DatabaseException(java.lang.String msg,
                         java.sql.SQLException e)
constructor initializes the sqlErrorCode

Parameters:
msg - error message
e - corresponding SQLException

DatabaseException

public DatabaseException(java.lang.String msg)
constructor initializes the sqlErrorCode to -1 and the SQLState to null

Parameters:
s -
Method Detail

isDataIntegrityViolation

public abstract boolean isDataIntegrityViolation()
was db exception caused by a data integrity violation?


isUniqueConstraintViolation

public abstract boolean isUniqueConstraintViolation()
was db exception caused by unique constraint violation (duplicate record)


isBadSQLGrammar

public abstract boolean isBadSQLGrammar()
was db exception caused by bad sql grammer (a typo)?


isNonExistentTableOrViewOrCol

public abstract boolean isNonExistentTableOrViewOrCol()
was db exception caused by referencing a non existent table or view?


isInvalidBindVariableName

public abstract boolean isInvalidBindVariableName()
was db exception caused by referencing a invalid bind parameter name?


isDatabaseUnavailable

public abstract boolean isDatabaseUnavailable()
was db exception caused by database being unavailable?


isRowlockOrTimedOut

public abstract boolean isRowlockOrTimedOut()
was db exception caused by a row lock error or some other sql querty timeout?


isVarParameterUnbound

public abstract boolean isVarParameterUnbound()
was db exception caused by a an unbound variable (parameter)?


getSQLErrorCode

public int getSQLErrorCode()
Get the SQLErrorCode

Returns:
sqlErrorCode as an integer

getSQLState

public java.lang.String getSQLState()
get the SQLState

Returns:
SQLState as String