Search in sources :

Example 21 with SQLFailureException

use of org.dbflute.exception.SQLFailureException in project dbflute-core by dbflute.

the class DfSqlFileRunnerBase method setupConnection.

protected void setupConnection() {
    if (_dataSource == null) {
        // means lazy connection (temporarily connect other users)
        return;
    }
    try {
        _currentConnection = _dataSource.getConnection();
        final boolean autoCommit = _runInfo.isAutoCommit();
        // means begin transaction
        _beginTransaction = !autoCommit;
        _currentConnection.setAutoCommit(autoCommit);
    } catch (SQLException e) {
        String msg = "DataSource#getConnection() threw the exception:";
        msg = msg + " dataSource=" + _dataSource;
        throw new SQLFailureException(msg, e);
    }
}
Also used : SQLException(java.sql.SQLException) SQLFailureException(org.dbflute.exception.SQLFailureException)

Example 22 with SQLFailureException

use of org.dbflute.exception.SQLFailureException in project dbflute-core by dbflute.

the class DfJdbcFacadeTest method test_handleSQLException.

public void test_handleSQLException() throws Exception {
    // ## Arrange ##
    DfJdbcFacade facade = new DfJdbcFacade((DataSource) null);
    String sql = "select * from dual";
    SQLException e = new SQLException("foo message");
    try {
        // ## Act ##
        facade.handleSQLException(sql, e);
        // ## Assert ##
        fail();
    } catch (SQLFailureException actual) {
        // OK
        log(actual.getMessage());
        assertEquals(e, actual.getCause());
    }
}
Also used : SQLException(java.sql.SQLException) DfJdbcFacade(org.dbflute.helper.jdbc.facade.DfJdbcFacade) SQLFailureException(org.dbflute.exception.SQLFailureException)

Example 23 with SQLFailureException

use of org.dbflute.exception.SQLFailureException in project dbflute-core by dbflute.

the class BehaviorCommandInvoker method handleExecutionException.

protected void handleExecutionException(RuntimeException cause) {
    if (cause instanceof SQLFailureException) {
        throw cause;
    }
    final SQLExceptionDigger digger = getSQLExceptionDigger();
    final SQLException sqlEx = digger.digUp(cause);
    if (sqlEx != null) {
        handleSQLException(sqlEx);
    } else {
        throw cause;
    }
}
Also used : SQLException(java.sql.SQLException) SQLExceptionDigger(org.dbflute.jdbc.SQLExceptionDigger) SQLFailureException(org.dbflute.exception.SQLFailureException)

Example 24 with SQLFailureException

use of org.dbflute.exception.SQLFailureException in project dbflute-core by dbflute.

the class DfConventionalTakeAsserter method extractTableList.

protected List<DfTableMeta> extractTableList() {
    Connection conn = null;
    try {
        conn = _dataSource.getConnection();
        final DatabaseMetaData metaData = conn.getMetaData();
        return new DfTableExtractor().getTableList(metaData, _dataSource.getSchema());
    } catch (SQLException e) {
        throw new SQLFailureException("Failed to extract table meta list: " + _dataSource, e);
    } finally {
        if (conn != null) {
            try {
                conn.close();
            } catch (SQLException ignored) {
            }
        }
    }
}
Also used : DfTableExtractor(org.dbflute.logic.jdbc.metadata.basic.DfTableExtractor) SQLException(java.sql.SQLException) Connection(java.sql.Connection) DatabaseMetaData(java.sql.DatabaseMetaData) SQLFailureException(org.dbflute.exception.SQLFailureException)

Example 25 with SQLFailureException

use of org.dbflute.exception.SQLFailureException in project dbflute-core by dbflute.

the class DfAlterCheckProcess method reflectTakeFinallyResultToFinalInfo.

protected void reflectTakeFinallyResultToFinalInfo(DfAlterCheckFinalInfo finalInfo, DfTakeFinallyFinalInfo takeFinally) {
    final List<String> detailMessageList = takeFinally.getDetailMessageList();
    for (String detailMessage : detailMessageList) {
        finalInfo.addDetailMessage(detailMessage);
    }
    final SQLFailureException breakCause = takeFinally.getBreakCause();
    if (breakCause != null) {
        finalInfo.setBreakCause(breakCause);
    }
    final DfTakeFinallyAssertionFailureException assertionEx = takeFinally.getAssertionEx();
    if (assertionEx != null) {
        finalInfo.setTakeFinallyAssertionEx(assertionEx);
    }
    if (takeFinally.isFailure()) {
        finalInfo.setFailure(true);
    }
}
Also used : DfTakeFinallyAssertionFailureException(org.dbflute.exception.DfTakeFinallyAssertionFailureException) SQLFailureException(org.dbflute.exception.SQLFailureException)

Aggregations

SQLFailureException (org.dbflute.exception.SQLFailureException)31 SQLException (java.sql.SQLException)19 Statement (java.sql.Statement)9 ResultSet (java.sql.ResultSet)7 LinkedHashMap (java.util.LinkedHashMap)5 ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)5 ArrayList (java.util.ArrayList)4 Connection (java.sql.Connection)3 DatabaseMetaData (java.sql.DatabaseMetaData)3 DfTakeFinallyAssertionFailureException (org.dbflute.exception.DfTakeFinallyAssertionFailureException)3 DfProcedureMeta (org.dbflute.logic.jdbc.metadata.info.DfProcedureMeta)3 DfTableMeta (org.dbflute.logic.jdbc.metadata.info.DfTableMeta)3 File (java.io.File)2 Map (java.util.Map)2 ErrorContinuedSql (org.dbflute.helper.jdbc.sqlfile.DfSqlFileRunnerResult.ErrorContinuedSql)2 DfProcedureExtractor (org.dbflute.logic.jdbc.metadata.basic.DfProcedureExtractor)2 DfTableExtractor (org.dbflute.logic.jdbc.metadata.basic.DfTableExtractor)2 DfTakeFinallyProcess (org.dbflute.logic.replaceschema.process.DfTakeFinallyProcess)2 DfClassificationElement (org.dbflute.properties.assistant.classification.DfClassificationElement)2 DfClassificationJdbcCloser (org.dbflute.properties.assistant.classification.coins.DfClassificationJdbcCloser)2