Search in sources :

Example 1 with SQLExceptionTranslator

use of org.springframework.jdbc.support.SQLExceptionTranslator in project tutorials by eugenp.

the class ExceptionTranslator method exception.

@Override
public void exception(ExecuteContext context) {
    SQLDialect dialect = context.configuration().dialect();
    SQLExceptionTranslator translator = new SQLErrorCodeSQLExceptionTranslator(dialect.name());
    context.exception(translator.translate("Access database using jOOQ", context.sql(), context.sqlException()));
}
Also used : SQLErrorCodeSQLExceptionTranslator(org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator) SQLExceptionTranslator(org.springframework.jdbc.support.SQLExceptionTranslator) SQLErrorCodeSQLExceptionTranslator(org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator) SQLDialect(org.jooq.SQLDialect)

Example 2 with SQLExceptionTranslator

use of org.springframework.jdbc.support.SQLExceptionTranslator in project jOOQ by jOOQ.

the class ExceptionTranslator method exception.

@Override
public void exception(ExecuteContext ctx) {
    // [#4391] Translate only SQLExceptions
    if (ctx.sqlException() != null) {
        SQLDialect dialect = ctx.dialect();
        SQLExceptionTranslator translator = (dialect != null) ? new SQLErrorCodeSQLExceptionTranslator(dialect.thirdParty().springDbName()) : new SQLStateSQLExceptionTranslator();
        ctx.exception(translator.translate("jOOQ", ctx.sql(), ctx.sqlException()));
    }
}
Also used : SQLErrorCodeSQLExceptionTranslator(org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator) SQLExceptionTranslator(org.springframework.jdbc.support.SQLExceptionTranslator) SQLStateSQLExceptionTranslator(org.springframework.jdbc.support.SQLStateSQLExceptionTranslator) SQLErrorCodeSQLExceptionTranslator(org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator) SQLDialect(org.jooq.SQLDialect) SQLStateSQLExceptionTranslator(org.springframework.jdbc.support.SQLStateSQLExceptionTranslator)

Example 3 with SQLExceptionTranslator

use of org.springframework.jdbc.support.SQLExceptionTranslator in project spring-boot by spring-projects.

the class JooqExceptionTranslator method exception.

@Override
public void exception(ExecuteContext context) {
    SQLExceptionTranslator translator = getTranslator(context);
    // The exception() callback is not only triggered for SQL exceptions but also for
    // "normal" exceptions. In those cases sqlException() returns null.
    SQLException exception = context.sqlException();
    while (exception != null) {
        handle(context, translator, exception);
        exception = exception.getNextException();
    }
}
Also used : SQLExceptionTranslator(org.springframework.jdbc.support.SQLExceptionTranslator) SQLStateSQLExceptionTranslator(org.springframework.jdbc.support.SQLStateSQLExceptionTranslator) SQLErrorCodeSQLExceptionTranslator(org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator) SQLException(java.sql.SQLException)

Aggregations

SQLErrorCodeSQLExceptionTranslator (org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator)3 SQLExceptionTranslator (org.springframework.jdbc.support.SQLExceptionTranslator)3 SQLDialect (org.jooq.SQLDialect)2 SQLStateSQLExceptionTranslator (org.springframework.jdbc.support.SQLStateSQLExceptionTranslator)2 SQLException (java.sql.SQLException)1