Class SQLStateSQLExceptionTranslator

  extended by
      extended by
All Implemented Interfaces:

public class SQLStateSQLExceptionTranslator
extends AbstractFallbackSQLExceptionTranslator

SQLExceptionTranslator implementation that analyzes the SQL state in the SQLException based on the first two digits (the SQL state "class"). Detects standard SQL state values and well-known vendor-specific SQL states.

Not able to diagnose all problems, but is portable between databases and does not require special initialization (no database vendor detection, etc.). For more precise translation, consider SQLErrorCodeSQLExceptionTranslator.

Rod Johnson, Juergen Hoeller, Thomas Risberg
See Also:
SQLException.getSQLState(), SQLErrorCodeSQLExceptionTranslator

Field Summary
Fields inherited from class
Constructor Summary
Method Summary
protected  DataAccessException doTranslate(String task, String sql, SQLException ex)
          Template method for actually translating the given exception.
Methods inherited from class
buildMessage, getFallbackTranslator, setFallbackTranslator, translate
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public SQLStateSQLExceptionTranslator()
Method Detail


protected DataAccessException doTranslate(String task,
                                          String sql,
                                          SQLException ex)
Description copied from class: AbstractFallbackSQLExceptionTranslator
Template method for actually translating the given exception.

The passed-in arguments will have been pre-checked. Furthermore, this method is allowed to return null to indicate that no exception match has been found and that fallback translation should kick in.

Specified by:
doTranslate in class AbstractFallbackSQLExceptionTranslator
task - readable text describing the task being attempted
sql - SQL query or update that caused the problem (may be null)
ex - the offending SQLException
the DataAccessException, wrapping the SQLException; or null if no exception match found