/** * 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" ); }
protected SQLExceptionConverter getSQLExceptionConverter() { return getSQLExceptionHelper().getSqlExceptionConverter(); }
private void releaseConnection() { if ( physicalConnection == null ) { return; } // todo : is this the right place for these observer calls? observer.jdbcConnectionReleaseStart(); try { if ( !physicalConnection.isClosed() ) { sqlExceptionHelper.logAndClearWarnings( physicalConnection ); } jdbcConnectionAccess.releaseConnection( physicalConnection ); } catch (SQLException e) { throw sqlExceptionHelper.convert( e, "Unable to release JDBC Connection" ); } finally { observer.jdbcConnectionReleaseEnd(); physicalConnection = null; getResourceRegistry().releaseResources(); } }
public void release() throws SQLException { new SqlExceptionHelper().logAndClearWarnings( connection ); if ( toggleAutoCommit ) { connection.setAutoCommit( false ); } connection = null; } }
public static PersistenceException toV5HibernateException(final SQLException ex, final String message) { return new SqlExceptionHelper(true).convert(ex, message); }
@SuppressWarnings("deprecation") private SqlExceptionHelper buildSqlExceptionHelper(Dialect dialect, boolean logWarnings) { final StandardSQLExceptionConverter sqlExceptionConverter = new StandardSQLExceptionConverter(); sqlExceptionConverter.addDelegate( dialect.buildSQLExceptionConversionDelegate() ); sqlExceptionConverter.addDelegate( new SQLExceptionTypeDelegate( dialect ) ); // todo : vary this based on extractedMetaDataSupport.getSqlStateType() sqlExceptionConverter.addDelegate( new SQLStateConversionDelegate( dialect ) ); return new SqlExceptionHelper( sqlExceptionConverter, logWarnings ); }
public void release() throws SQLException { sqlExceptionHelper.logAndClearWarnings( connection ); if ( toggleAutoCommit ) { connection.setAutoCommit( false ); } connection = null; } }
/** * Convert an SQLException using the current converter, doing some logging first. * * @param sqlException The exception to convert * @param message An error message. * @param sql The SQL being executed when the exception occurred * * @return The converted exception */ public JDBCException convert(SQLException sqlException, String message, String sql) { logExceptions( sqlException, message + " [" + sql + "]" ); return sqlExceptionConverter.convert( sqlException, message, sql ); }
/** * Standard (legacy) behavior for logging warnings associated with a JDBC {@link Connection} and clearing them. * <p/> * Calls {@link #handleAndClearWarnings(Connection, WarningHandler)} using {@link #STANDARD_WARNING_HANDLER} * * @param connection The JDBC connection potentially containing warnings */ public void logAndClearWarnings(Connection connection) { handleAndClearWarnings( connection, STANDARD_WARNING_HANDLER ); }
/** * General purpose handling of warnings associated with a JDBC {@link Connection}. * * @param connection The JDBC connection potentially containing warnings * @param handler The handler for each individual warning in the stack. * * @see #walkWarnings */ @SuppressWarnings({"ThrowableResultOfMethodCallIgnored"}) public void handleAndClearWarnings( Connection connection, WarningHandler handler) { try { if ( logWarnings ) { walkWarnings( connection.getWarnings(), handler ); } } catch (SQLException sqle) { // workaround for WebLogic LOG.debug( "could not log warnings", sqle ); } try { // Sybase fail if we don't do that, sigh... connection.clearWarnings(); } catch (SQLException sqle) { LOG.debug( "could not clear warnings", sqle ); } }
public void release() throws SQLException { new SqlExceptionHelper().logAndClearWarnings( connection ); if ( toggleAutoCommit ) { connection.setAutoCommit( false ); } connection = null; } }
public SchemaExport( ConnectionHelper connectionHelper, String[] dropSql, String[] createSql) { this.connectionHelper = connectionHelper; this.dropSQL = dropSql; this.createSQL = createSql; this.importFiles = ""; this.sqlStatementLogger = new SqlStatementLogger( false, true ); this.sqlExceptionHelper = new SqlExceptionHelper(); this.formatter = FormatStyle.DDL.getFormatter(); }
public void release() throws SQLException { // we only release the connection if ( connection != null ) { sqlExceptionHelper.logAndClearWarnings( connection ); if ( toggleAutoCommit ) { connection.setAutoCommit( false ); } provider.closeConnection( connection ); connection = null; } } }
@Override protected int determineRowCount(int reportedRowCount, PreparedStatement statement) { try { return toCallableStatement( statement ).getInt( parameterPosition ); } catch (SQLException sqle) { sqlExceptionHelper.logExceptions( sqle, "could not extract row counts from CallableStatement" ); throw new GenericJDBCException( "could not extract row counts from CallableStatement", sqle ); } }
public void logAndClearWarnings(Statement statement) { handleAndClearWarnings( statement, STANDARD_WARNING_HANDLER ); }
walkWarnings( statement.getWarnings(), handler );
@Override public void cancelLastQuery() { try { if (lastQuery != null) { lastQuery.cancel(); } } catch (SQLException sqle) { throw exceptionHelper.convert( sqle, "Cannot cancel query" ); } finally { lastQuery = null; } }
public void release() throws SQLException { // we only release the connection if ( connection != null ) { new SqlExceptionHelper().logAndClearWarnings( connection ); if ( toggleAutoCommit ) { connection.setAutoCommit( false ); } provider.closeConnection( connection ); connection = null; } } }
/** * Retrieves the SQLExceptionConverter in effect for this SessionFactory. * * @return The SQLExceptionConverter for this SessionFactory. * * @deprecated since 5.0; use {@link JdbcServices#getSqlExceptionHelper()} -> * {@link SqlExceptionHelper#getSqlExceptionConverter()} instead as obtained from {@link #getServiceRegistry()} */ @Deprecated default SQLExceptionConverter getSQLExceptionConverter() { return getServiceRegistry().getService( JdbcServices.class ).getSqlExceptionHelper().getSqlExceptionConverter(); }
public SchemaExport( ConnectionHelper connectionHelper, String[] dropSql, String[] createSql) { this.connectionHelper = connectionHelper; this.dropSQL = dropSql; this.createSQL = createSql; this.importFiles = ""; this.sqlStatementLogger = new SqlStatementLogger( false, true ); this.sqlExceptionHelper = new SqlExceptionHelper(); this.formatter = FormatStyle.DDL.getFormatter(); }