/** * Convert an SQLException using the current converter, doing some logging first. * * @param sqlException The exception to convert * @param message An error message. * * @return The converted exception */ public JDBCException convert(SQLException sqlException, String message) { return convert( sqlException, message, "n/a" ); }
@Override public void cancelLastQuery() { try { if (lastQuery != null) { lastQuery.cancel(); } } catch (SQLException sqle) { throw exceptionHelper.convert( sqle, "Cannot cancel query" ); } finally { lastQuery = null; } }
@Override public DatabaseMetaData getJdbcDatabaseMetaData() { if ( jdbcDatabaseMetaData == null ) { try { jdbcDatabaseMetaData = getJdbcConnection().getMetaData(); } catch (SQLException e) { throw jdbcEnvironment.getSqlExceptionHelper().convert( e, "Unable to obtain JDBC DatabaseMetaData" ); } } return jdbcDatabaseMetaData; }
@Override public int executeUpdate(PreparedStatement statement) { try { jdbcExecuteStatementStart(); return statement.executeUpdate(); } catch (SQLException e) { throw sqlExceptionHelper.convert( e, "could not execute statement" ); } finally { jdbcExecuteStatementEnd(); } }
@Override public Connection getJdbcConnection() { if ( jdbcConnection == null ) { try { jdbcConnection = jdbcConnectionAccess.obtainConnection(); } catch (SQLException e) { throw jdbcEnvironment.getSqlExceptionHelper().convert( e, "Unable to obtain JDBC Connection" ); } } return jdbcConnection; }
@Override public JDBCException convert(SQLException e, String message) { return sharedSessionContract.getJdbcServices().getSqlExceptionHelper().convert( e, message ); }
protected JDBCException convertSQLException(SQLException sqlException, String message) { return extractionContext.getJdbcEnvironment().getSqlExceptionHelper().convert( sqlException, message ); }
private Statement jdbcStatement() { if ( jdbcStatement == null ) { try { this.jdbcStatement = ddlTransactionIsolator.getIsolatedConnection().createStatement(); } catch (SQLException e) { throw ddlTransactionIsolator.getJdbcContext().getSqlExceptionHelper().convert( e, "Unable to create JDBC Statement for DDL execution" ); } } return jdbcStatement; }
@Override public int executeUpdate(Statement statement, String sql) { sqlStatementLogger.logStatement( sql ); try { jdbcExecuteStatementStart(); return statement.executeUpdate( sql ); } catch (SQLException e) { throw sqlExceptionHelper.convert( e, "could not execute statement" ); } finally { jdbcExecuteStatementEnd(); } }
@Override public Statement createStatement() { try { final Statement statement = connection().createStatement(); jdbcCoordinator.getResourceRegistry().register( statement, true ); return statement; } catch ( SQLException e ) { throw sqlExceptionHelper().convert( e, "could not create statement" ); } }
@Override public void release() { if ( jdbcConnection != null ) { try { jdbcContext.getJdbcConnectionAccess().releaseConnection( jdbcConnection ); } catch (SQLException e) { throw jdbcContext.getSqlExceptionHelper().convert( e, "Unable to release JDBC Connection used for DDL execution" ); } } } }
protected JDBCException convert(SQLException sqle, String message) { return getSession().getFactory().getSQLExceptionHelper().convert( sqle, message ); }
@Override public void beforeFirst() { try { getResultSet().beforeFirst(); } catch (SQLException e) { throw getSession().getFactory().getSQLExceptionHelper().convert( e, "exception calling beforeFirst()" ); } currentRow = null; currentPosition = 0; }
protected JDBCException convert(SQLException e, String message) { return context.getSession().getJdbcServices().getSqlExceptionHelper().convert( e, message, context.getSql() ); }
protected JDBCException convert( SQLException e, String message, String sql) { throw factory().getServiceRegistry().getService( JdbcServices.class ).getSqlExceptionHelper().convert( e, message, sql ); }
protected JDBCException convertSqlException(String message, SQLException e) { // if JdbcServices#getSqlExceptionHelper is available, use it... final JdbcServices jdbcServices = serviceRegistry.getService( JdbcServices.class ); if ( jdbcServices != null && jdbcServices.getSqlExceptionHelper() != null ) { return jdbcServices.getSqlExceptionHelper().convert( e, message, null ); } // likely we are still in the process of initializing the ServiceRegistry, so use the simplified // SQLException conversion return simpleConverterAccess.getValue().convert( e, message, null ); }
@Override public <T> T coordinateWork(WorkExecutorVisitable<T> work) { final Connection connection = getLogicalConnection().getPhysicalConnection(); try { final T result = work.accept( new WorkExecutor<T>(), connection ); afterStatementExecution(); return result; } catch ( SQLException e ) { throw sqlExceptionHelper().convert( e, "error executing work" ); } }
private boolean isResultSetEmpty() { try { return currentPosition == 0 && !getResultSet().isBeforeFirst() && !getResultSet().isAfterLast(); } catch (SQLException e) { throw getSession().getFactory().getSQLExceptionHelper().convert( e, "Could not determine if resultset is empty due to exception calling isBeforeFirst or isAfterLast()" ); } }
@Override public NClob mergeNClob(NClob original, NClob target, SharedSessionContractImplementor session) { if ( original == null && target == null ) { return null; } try { final LobCreator lobCreator = session.getFactory().getServiceRegistry().getService( JdbcServices.class ).getLobCreator( session ); return original == null ? lobCreator.createNClob( "" ) : lobCreator.createNClob( original.getCharacterStream(), original.length() ); } catch (SQLException e) { throw session.getFactory().getSQLExceptionHelper().convert( e, "unable to merge NCLOB data" ); } } };
protected interface InclusionChecker { boolean includeProperty(int propertyNumber); }