Search in sources :

Example 16 with DfJDBCException

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

the class DfDataSourceHandler method commit.

public void commit() throws SQLException {
    Connection conn = null;
    try {
        conn = getCachedConnection();
        if (conn == null) {
            // if no cache, do nothing
            return;
        }
        if (!conn.getAutoCommit()) {
            _log.info("...commit()");
            conn.commit();
        }
    } catch (SQLException e) {
        String msg = "Failed to commit the conection: conn=" + conn;
        throw new DfJDBCException(msg, e);
    } finally {
        if (conn != null) {
            try {
                conn.close();
            } catch (SQLException ignored) {
            }
        }
    }
}
Also used : DfJDBCException(org.dbflute.exception.DfJDBCException) SQLException(java.sql.SQLException) Connection(java.sql.Connection)

Example 17 with DfJDBCException

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

the class DfProcedureExtractor method throwProcedureListGettingFailureException.

protected void throwProcedureListGettingFailureException(UnifiedSchema unifiedSchema, String procedureName, Exception e) throws SQLException {
    final boolean forSqlEx = e instanceof SQLException;
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("Failed to get a list of procedures.");
    br.addItem("Unified Schema");
    br.addElement(unifiedSchema);
    br.addItem("Current Procedure");
    br.addElement(procedureName);
    br.addItem(forSqlEx ? "Caused SQLException" : "Unexpected Exception");
    br.addElement(e.getClass().getName());
    br.addElement(e.getMessage());
    final String msg = br.buildExceptionMessage();
    if (forSqlEx) {
        throw new DfJDBCException(msg, (SQLException) e);
    } else {
        throw new DfProcedureListGettingFailureException(msg, e);
    }
}
Also used : DfJDBCException(org.dbflute.exception.DfJDBCException) SQLException(java.sql.SQLException) ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) DfProcedureListGettingFailureException(org.dbflute.exception.DfProcedureListGettingFailureException)

Aggregations

DfJDBCException (org.dbflute.exception.DfJDBCException)17 SQLException (java.sql.SQLException)12 Connection (java.sql.Connection)6 ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)6 DfColumnMeta (org.dbflute.logic.jdbc.metadata.info.DfColumnMeta)5 File (java.io.File)3 ArrayList (java.util.ArrayList)3 BufferedReader (java.io.BufferedReader)2 FileInputStream (java.io.FileInputStream)2 InputStreamReader (java.io.InputStreamReader)2 PreparedStatement (java.sql.PreparedStatement)2 List (java.util.List)2 DfDelimiterDataRegistrationFailureException (org.dbflute.exception.DfDelimiterDataRegistrationFailureException)2 DfXlsDataRegistrationFailureException (org.dbflute.exception.DfXlsDataRegistrationFailureException)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 Driver (java.sql.Driver)1 Statement (java.sql.Statement)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1