Example usage for org.springframework.jdbc.support SQLStateSQLExceptionTranslator SQLStateSQLExceptionTranslator

List of usage examples for org.springframework.jdbc.support SQLStateSQLExceptionTranslator SQLStateSQLExceptionTranslator

Introduction

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

Prototype

SQLStateSQLExceptionTranslator

Source Link

Usage

From source file:org.cfr.capsicum.support.ExceptionTranslator.java

/**
 * Returns the JDBC exception translator for this instance. If not
 * initialized, creates default portable SQLStateSQLExceptionTranslator, as
 * Cayenne configuration can span multiple DataSources,
 */// w w w.ja v a  2 s.c o m
// TODO: if we can propagate DataNode that caused the exception, we can get
// a DataSource for exception and use SQLErrorCodeSQLExceptionTranslator.
public SQLExceptionTranslator getJdbcExceptionTranslator() {
    if (this.jdbcExceptionTranslator == null) {
        this.jdbcExceptionTranslator = new SQLStateSQLExceptionTranslator();
    }
    return this.jdbcExceptionTranslator;
}

From source file:sample.jooq.JooqExceptionTranslator.java

private SQLExceptionTranslator getTranslator(ExecuteContext context) {
    SQLDialect dialect = context.configuration().dialect();
    if (dialect != null) {
        return new SQLErrorCodeSQLExceptionTranslator(dialect.name());
    }//from w w w . j  ava  2s.co  m
    return new SQLStateSQLExceptionTranslator();
}

From source file:test.RowMapperTests.java

@Override
@Before/*from   w ww  .ja v a 2  s  .c  o m*/
public void setUp() throws SQLException {
    connection = mock(Connection.class);
    statement = mock(Statement.class);
    preparedStatement = mock(PreparedStatement.class);
    resultSet = mock(ResultSet.class);
    given(connection.createStatement()).willReturn(statement);
    given(connection.prepareStatement(anyString())).willReturn(preparedStatement);
    given(statement.executeQuery(anyString())).willReturn(resultSet);
    given(preparedStatement.executeQuery()).willReturn(resultSet);
    given(resultSet.next()).willReturn(true, true, false);
    given(resultSet.getString(1)).willReturn("tb1", "tb2");
    given(resultSet.getInt(2)).willReturn(1, 2);
    template = new JdbcTemplate();
    template.setDataSource(new SingleConnectionDataSource(connection, false));
    template.setExceptionTranslator(new SQLStateSQLExceptionTranslator());
    template.afterPropertiesSet();
}

From source file:me.lty.jooq.ExceptionTranslator.java

@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()));
    }/*w w w .  j  a v  a  2s  .  co m*/
}

From source file:ch.difty.sipamato.persistance.jooq.config.ExceptionTranslator.java

@Override
public void exception(ExecuteContext ctx) {

    // [#4391] Translate only SQLExceptions
    if (ctx.sqlException() != null) {
        SQLDialect dialect = ctx.dialect();

        // @formatter:off
        SQLExceptionTranslator translator = (dialect != null)
                ? new SQLErrorCodeSQLExceptionTranslator(dialect.thirdParty().springDbName())
                : new SQLStateSQLExceptionTranslator();
        // @formatter:on

        ctx.exception(translator.translate("jOOQ", ctx.sql(), ctx.sqlException()));
    }//  ww w.  j  av a 2  s.  c o m
}

From source file:org.guzz.web.context.spring.TransactionManagerUtils.java

/**
 * Create an appropriate SQLExceptionTranslator for the given TransactionManager.
 * If a DataSource is found, a SQLErrorCodeSQLExceptionTranslator for the DataSource
 * is created; else, a SQLStateSQLExceptionTranslator as fallback.
 * @param transactionManager the TransactionManager to create the translator for
 * @return the SQLExceptionTranslator// ww  w  . j a  v  a  2 s .  c  o  m
 * @see #getDataSource
 * @see org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator
 * @see org.springframework.jdbc.support.SQLStateSQLExceptionTranslator
 */
public static SQLExceptionTranslator newJdbcExceptionTranslator() {
    return new SQLStateSQLExceptionTranslator();
}

From source file:com.chillenious.common.db.jooq.ExceptionTranslator.java

private SQLExceptionTranslator translator() {
    return ds == null ? new SQLStateSQLExceptionTranslator() : new SQLErrorCodeSQLExceptionTranslator(ds);
}

From source file:pl.joegreen.edward.persistence.ExceptionTranslator.java

@Override
public void exception(ExecuteContext ctx) {
    SQLDialect dialect = ctx.configuration().dialect();
    SQLExceptionTranslator translator = (dialect != null)
            ? new SQLErrorCodeSQLExceptionTranslator(dialect.name())
            : new SQLStateSQLExceptionTranslator();

    if (ctx.sqlException() != null) {
        ctx.exception(translator.translate("jOOQ", ctx.sql(), ctx.sqlException()));
    }/*from   w  w  w  .j av  a  2 s.c o  m*/
}

From source file:com.bitdubai.fermat.node.db.exception.ExceptionTranslator.java

@Override
public void exception(ExecuteContext ctx) {
    SQLDialect dialect = ctx.configuration().dialect();
    SQLExceptionTranslator translator = (dialect != null)
            ? new SQLErrorCodeSQLExceptionTranslator(dialect.name())
            : new SQLStateSQLExceptionTranslator();

    ctx.exception(translator.translate("jOOQ", ctx.sql(), ctx.sqlException()));
}

From source file:de.eiswind.vaadin.spring.jooq.ExceptionTranslator.java

@Override
public void exception(ExecuteContext ctx) {
    if (ctx.sqlException() != null) {
        SQLDialect dialect = ctx.configuration().dialect();
        SQLExceptionTranslator translator = (dialect != null)
                ? new SQLErrorCodeSQLExceptionTranslator(dialect.name())
                : new SQLStateSQLExceptionTranslator();

        ctx.exception(translator.translate("jOOQ", ctx.sql(), ctx.sqlException()));
    }/*from   ww  w .jav  a2s .co m*/
}