spring-framework / org.springframework.jdbc.support / SQLErrorCodeSQLExceptionTranslator

SQLErrorCodeSQLExceptionTranslator

open class SQLErrorCodeSQLExceptionTranslator : AbstractFallbackSQLExceptionTranslator

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.

Author
Rod Johnson

Author
Thomas Risberg

Author
Juergen Hoeller

See Also
SQLErrorCodesFactorySQLStateSQLExceptionTranslator

Constructors

<init>

SQLErrorCodeSQLExceptionTranslator()

Constructor for use as a JavaBean. The SqlErrorCodes or DataSource property must be set.

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.

SQLErrorCodeSQLExceptionTranslator(dbName: String)

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.

SQLErrorCodeSQLExceptionTranslator(sec: SQLErrorCodes)

Create a SQLErrorCode translator given these error codes. Does not require a database metadata lookup to be performed using a connection.

Functions

getSqlErrorCodes

open fun getSqlErrorCodes(): SQLErrorCodes

Return the error codes used by this translator. Usually determined via a DataSource.

setDataSource

open fun setDataSource(dataSource: DataSource): Unit

Set the DataSource for this translator.

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

setDatabaseProductName

open fun setDatabaseProductName(dbName: String): Unit

Set the database product name for this translator.

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

setSqlErrorCodes

open fun setSqlErrorCodes(sec: SQLErrorCodes): Unit

Set custom error codes to be used for translation.