Save This Page
Home » spring-framework-2.5.6-with-dependencies » org.springframework » jdbc » support » [javadoc | source]
org.springframework.jdbc.support
public class: SQLErrorCodeSQLExceptionTranslator [javadoc | source]
java.lang.Object
   org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator
      org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator

All Implemented Interfaces:
    SQLExceptionTranslator

Implementation of SQLExceptionTranslator that analyzes vendor-specific error codes. More precise than an implementation based on SQL state, but heavily vendor-specific.

This class applies the following matching rules:

The configuration file named "sql-error-codes.xml" is by default read from this package. It can be overridden through a file of the same name in the root of the class path (e.g. in the "/WEB-INF/classes" directory), as long as the Spring JDBC package is loaded from the same ClassLoader.

Fields inherited from org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator:
logger
Constructor:
 public SQLErrorCodeSQLExceptionTranslator() 
 public SQLErrorCodeSQLExceptionTranslator(DataSource dataSource) 
    Create a SQL error code translator for the given DataSource. Invoking this constructor will cause a Connection to be obtained from the DataSource to get the metadata.
    Parameters:
    dataSource - DataSource to use to find metadata and establish which error codes are usable
    Also see:
    SQLErrorCodesFactory
 public SQLErrorCodeSQLExceptionTranslator(String dbName) 
    Create a SQL error code translator for the given database product name. Invoking this constructor will avoid obtaining a Connection from the DataSource to get the metadata.
    Parameters:
    dbName - the database product name that identifies the error codes entry
    Also see:
    SQLErrorCodesFactory
    java.sql.DatabaseMetaData#getDatabaseProductName()
 public SQLErrorCodeSQLExceptionTranslator(SQLErrorCodes sec) 
    Create a SQLErrorCode translator given these error codes. Does not require a database metadata lookup to be performed using a connection.
    Parameters:
    sec - error codes
Method from org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator Summary:
createCustomException,   customTranslate,   doTranslate,   getSqlErrorCodes,   setDataSource,   setDatabaseProductName,   setSqlErrorCodes
Methods from org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator:
buildMessage,   doTranslate,   getFallbackTranslator,   setFallbackTranslator,   translate
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator Detail:
 protected DataAccessException createCustomException(String task,
    String sql,
    SQLException sqlEx,
    Class exceptionClass) 
    Create a custom DataAccessException, based on a given exception class from a CustomSQLErrorCodesTranslation definition.
 protected DataAccessException customTranslate(String task,
    String sql,
    SQLException sqlEx) 
    Subclasses can override this method to attempt a custom mapping from SQLException to DataAccessException.
 protected DataAccessException doTranslate(String task,
    String sql,
    SQLException ex) 
 public SQLErrorCodes getSqlErrorCodes() 
    Return the error codes used by this translator. Usually determined via a DataSource.
 public  void setDataSource(DataSource dataSource) 
    Set the DataSource for this translator.

    Setting this property will cause a Connection to be obtained from the DataSource to get the metadata.

 public  void setDatabaseProductName(String dbName) 
    Set the database product name for this translator.

    Setting this property will avoid obtaining a Connection from the DataSource to get the metadata.

 public  void setSqlErrorCodes(SQLErrorCodes sec) 
    Set custom error codes to be used for translation.