}
}
}
public Object execute(CallableStatementCallback action, List<SqlVisitor> sqlVisitors) throws DatabaseException {
DatabaseConnection con = database.getConnection();
if (con instanceof OfflineConnection) {
throw new DatabaseException("Cannot execute commands against an offline database");
}
CallableStatement stmt = null;
try {
String sql = applyVisitors(action.getStatement(), sqlVisitors)[0];
stmt = ((JdbcConnection) con).getUnderlyingConnection().prepareCall(sql);
return action.doInCallableStatement(stmt);
}
catch (SQLException ex) {
// Release Connection early, to avoid potential connection pool deadlock
// in the case when the exception translator hasn't been initialized yet.
JdbcUtils.closeStatement(stmt);
stmt = null;
throw new DatabaseException("Error executing SQL " + StringUtils.join(applyVisitors(action.getStatement(), sqlVisitors), "; on "+ con.getURL())+": "+ex.getMessage(), ex);
}
finally {
JdbcUtils.closeStatement(stmt);
}
}