Example usage for org.springframework.jdbc.support SQLErrorCodes getCustomSqlExceptionTranslator

List of usage examples for org.springframework.jdbc.support SQLErrorCodes getCustomSqlExceptionTranslator

Introduction

In this page you can find the example usage for org.springframework.jdbc.support SQLErrorCodes getCustomSqlExceptionTranslator.

Prototype

@Nullable
    public SQLExceptionTranslator getCustomSqlExceptionTranslator() 

Source Link

Usage

From source file:org.springframework.jdbc.support.SQLErrorCodesFactory.java

/**
 * Check the {@link CustomSQLExceptionTranslatorRegistry} for any entries.
 *//*from  ww  w .ja v  a 2s  . c  o m*/
private void checkCustomTranslatorRegistry(String databaseName, SQLErrorCodes errorCodes) {
    SQLExceptionTranslator customTranslator = CustomSQLExceptionTranslatorRegistry.getInstance()
            .findTranslatorForDatabase(databaseName);
    if (customTranslator != null) {
        if (errorCodes.getCustomSqlExceptionTranslator() != null && logger.isWarnEnabled()) {
            logger.warn("Overriding already defined custom translator '"
                    + errorCodes.getCustomSqlExceptionTranslator().getClass().getSimpleName() + " with '"
                    + customTranslator.getClass().getSimpleName()
                    + "' found in the CustomSQLExceptionTranslatorRegistry for database '" + databaseName
                    + "'");
        } else if (logger.isInfoEnabled()) {
            logger.info("Using custom translator '" + customTranslator.getClass().getSimpleName()
                    + "' found in the CustomSQLExceptionTranslatorRegistry for database '" + databaseName
                    + "'");
        }
        errorCodes.setCustomSqlExceptionTranslator(customTranslator);
    }
}