Top Description Fields Constructors Methods
org.springframework.jdbc.support

public final Class CustomSQLExceptionTranslatorRegistry

extends Object
Class Inheritance
Imports
java.util.HashMap, .Map, org.apache.commons.logging.Log, .LogFactory, org.springframework.lang.Nullable

Registry for custom org.springframework.jdbc.support.SQLExceptionTranslator instances associated with specific databases allowing for overriding translation based on values contained in the configuration file named "sql-error-codes.xml".
Author
Thomas Risberg
Since
3.1.1
See Also
SQLErrorCodesFactory

Field Summary

Modifier and TypeField and Description
private static final CustomSQLExceptionTranslatorRegistry
instance

Keep track of a single instance so we can return it to classes that request it.

private static final Log
private final Map<String, SQLExceptionTranslator>
translatorMap

Map registry to hold custom translators specific databases.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public SQLExceptionTranslator

Returns:

the custom translator, or null if none found
findTranslatorForDatabase
(String
the database name
dbName
)

Find a custom translator for the specified database.

public static CustomSQLExceptionTranslatorRegistry
getInstance()

Return the singleton instance.

public void
registerTranslator(String
the database name
dbName
,
SQLExceptionTranslator
the custom translator
translator
)

Register a new custom translator for the specified database name.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

instanceback to summary
private static final CustomSQLExceptionTranslatorRegistry instance

Keep track of a single instance so we can return it to classes that request it.

loggerback to summary
private static final Log logger
translatorMapback to summary
private final Map<String, SQLExceptionTranslator> translatorMap

Map registry to hold custom translators specific databases. Key is the database product name as defined in the org.springframework.jdbc.support.SQLErrorCodesFactory.

Constructor Detail

CustomSQLExceptionTranslatorRegistryback to summary
private CustomSQLExceptionTranslatorRegistry()

Create a new instance of the CustomSQLExceptionTranslatorRegistry class.

Not public to enforce Singleton design pattern.

Method Detail

findTranslatorForDatabaseback to summary
public SQLExceptionTranslator findTranslatorForDatabase(String dbName)

Find a custom translator for the specified database.

Parameters
dbName:String

the database name

Returns:SQLExceptionTranslator

the custom translator, or null if none found

Annotations
@Nullable
getInstanceback to summary
public static CustomSQLExceptionTranslatorRegistry getInstance()

Return the singleton instance.

registerTranslatorback to summary
public void registerTranslator(String dbName, SQLExceptionTranslator translator)

Register a new custom translator for the specified database name.

Parameters
dbName:String

the database name

translator:SQLExceptionTranslator

the custom translator