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);
}
}
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());
}
}
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;
}
}
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) {
}
}
}
}
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);
}
}
Aggregations