Exception handling in pureQuery code

Although pureQuery is based on JDBC, the pureQuery Data interface does not to require applications to handle checked exceptions. You do not have to enclose calls to pureQuery methods in try blocks.

Where it is possible, pureQuery catches SQLExceptions and other checked exceptions from the underlying JDBC driver. pureQuery then throws runtime exceptions that wrap the caught exceptions.

The pureQuery runtime exceptions are:

DataRuntimeException
This exception extends java.lang.RuntimeException, so it inherits the methods getMessage() and getCause().
To find information about a wrapped SQLException, you can use these methods:
public Integer getErrorCode()
If a DataRuntimeException wraps an SQLException, this method returns the SQLCODE.
If a DataRuntimeException does not wrap an SQLException, this method returns the value -99999.
public String getSQLSTATE()
If a DataRuntimeException wraps an SQLException, this method returns the SQLSTATE.
If a DataRuntimeException does not wrap an SQLException, this method returns the value "FFFFF".
public SqlErrorType getErrorType()
Whether a DataRuntimeException wraps an SQLException or not, this method returns one of the following values:
  • AUTHORIZATION_ERROR
  • CARDINALITY_VIOLATION
  • CONNECTION_ERROR
  • CONSTRAINT_VIOLATION
  • DUPLICATE_ROW_VIOLATION
  • FEATURE_NOT_SUPPORTED
  • FUNCTION_ERROR
  • INVALID_CURSOR_STATE
  • JDBC_DRIVER_ERROR
  • LIMIT_EXCEEDED
  • RESOURCE_UNAVAILABLE
  • STATIC_PACKAGE_NOT_FOUND
  • SYNTAX_ERROR
  • TIMEOUT_OR_DEADLOCK_NO_ROLLBACK
  • TIMEOUT_OR_DEADLOCK_WITH_ROLLBACK
  • UNCATEGORIZED_ERROR
To find out whether applications can recover from an SQLException, use the boolean isTransient() method. This method returns true if the SQLException is an instance of SQLTransientException, which is one of the three subclasses of SQLException that JDBC 4.0 introduces.
UpdateManyException
This exception extends DataRuntimeException, It provides the following methods:
  • getUpdateCounts() returns an int two dimensional array that contains the results of a batch update.
  • HeteroBatchSQLException[][] getHeteroBatchSQLExceptionArray() returns a two dimensional array that contains the row-specific HeteroBatchSQLExceptions and other error information returned from the batch update.
  • getBatchNonSpecificExceptions() returns a HeteroBatchSQLException from the batch update for any SQLExceptions that are not row specific. If there are multiple SQLException, the HeteroBatchSQLExceptions are chained together.
Note: If there are multiple exceptions, the exceptions are chained together. Call the getNextException() method to retrieve the HeteroBatchSQLExceptions that are chained together.

Feedback