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

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

Introduction

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

Prototype

public void setCustomSqlExceptionTranslator(@Nullable SQLExceptionTranslator customSqlExceptionTranslator) 

Source Link

Usage

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

/**
 * Check the {@link CustomSQLExceptionTranslatorRegistry} for any entries.
 *///from   w w w.j  a v a2  s .co  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);
    }
}