public void release() { JDBCExceptionReporter.logAndClearWarnings(connection); connection = null; } }
public static void logExceptions(SQLException ex) { logExceptions(ex, null); }
private void execute(String sql, Statement statement) { try { statement.executeUpdate(sql); SQLWarning warning = statement.getWarnings(); if (warning != null) { JDBCExceptionReporter.logWarnings(warning); statement.clearWarnings(); } } catch (SQLException e) { JDBCExceptionReporter.logExceptions(e, "failed to execute update"); exceptions.add(e); } }
private void closeConnection(Connection connection) { if (connectionProvider != null) { try { if (connection != null) { JDBCExceptionReporter.logAndClearWarnings(connection); connectionProvider.closeConnection(connection); } } catch (SQLException e) { exceptions.add(e); JDBCExceptionReporter.logExceptions(e); } finally { connectionProvider.close(); connectionProvider = null; } } }
public static void logWarnings(SQLWarning warning) { logWarnings(warning, null); }
public static void logAndClearWarnings(Connection connection) { if ( log.isWarnEnabled() ) { try { logWarnings( connection.getWarnings() ); connection.clearWarnings(); } catch (SQLException sqle) { //workaround for WebLogic log.debug("could not log warnings", sqle); } } }
/** * This implementation simply calls <code>Connection.close</code>. * * @see java.sql.Connection#close() */ public void closeConnection(Connection con) throws SQLException { try { con.close(); } catch (SQLException ex) { JDBCExceptionReporter.logExceptions(ex); throw ex; } }
public void release() throws SQLException { JDBCExceptionReporter.logAndClearWarnings( connection ); if ( toggleAutoCommit ) { connection.setAutoCommit( false ); } connection = null; } }
public static void logAndClearWarnings(Connection connection) { if ( log.isWarnEnabled() ) { try { logWarnings( connection.getWarnings() ); } 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); } }
/** * This implementation delegates to the underlying DataSource. * * @see javax.sql.DataSource#getConnection() */ public Connection getConnection() throws SQLException { try { return this.dataSource.getConnection(); } catch (SQLException ex) { JDBCExceptionReporter.logExceptions(ex); throw ex; } }
public void release() throws SQLException { // we only release the connection if ( connection != null ) { JDBCExceptionReporter.logAndClearWarnings( connection ); if ( toggleAutoCommit ) { connection.setAutoCommit( false ); } provider.closeConnection( connection ); connection = null; } } }
public static void logWarnings(SQLWarning warning, String message) { if ( log.isWarnEnabled() ) { if ( log.isDebugEnabled() && warning != null ) { message = StringHelper.isNotEmpty(message) ? message : DEFAULT_WARNING_MSG; log.debug( message, warning ); } while (warning != null) { StringBuffer buf = new StringBuffer(30) .append( "SQL Warning: ") .append( warning.getErrorCode() ) .append( ", SQLState: ") .append( warning.getSQLState() ); log.warn( buf.toString() ); log.warn( warning.getMessage() ); warning = warning.getNextWarning(); } } }
/** * This implementation delegates to the underlying DataSource. * @see javax.sql.DataSource#getConnection() */ @Override public Connection getConnection() throws SQLException { try { return this.dataSourceToUse.getConnection(); } catch (SQLException ex) { JDBCExceptionReporter.logExceptions(ex); throw ex; } }
private static List<SQLException> executeScript(final Connection connection, final String[] script) throws SQLException { List<SQLException> exceptions = Collections.emptyList(); final Statement statement = connection.createStatement(); try { for (final String line : script) { if (LOG.isLoggable(Level.FINE)) { LOG.fine(line); } try { statement.executeUpdate(line); if (statement.getWarnings() != null) { JDBCExceptionReporter.logAndClearWarnings(connection); } } catch (final SQLException e) { if (exceptions.isEmpty()) { exceptions = new ArrayList<SQLException>(); } exceptions.add(e); } } } finally { statement.close(); } return exceptions; }
public void abortBatch(SQLException sqle) { try { if (batchUpdate!=null) closeStatement(batchUpdate); } catch (SQLException e) { //noncritical, swallow and let the other propagate! JDBCExceptionReporter.logExceptions(e); } finally { batchUpdate=null; batchUpdateSQL=null; } }
public void release() throws SQLException { if ( connection!=null ) { JDBCExceptionReporter.logAndClearWarnings(connection); connectionProvider.closeConnection( connection ); connectionProvider.close(); } connection = null; } }
/** * Converts the given SQLException into Hibernate's JDBCException hierarchy, as well as performing * appropriate logging. * * @param converter The converter to use. * @param sqlException The exception to convert. * @param message An optional error message. * @return The converted JDBCException. */ public static JDBCException convert(SQLExceptionConverter converter, SQLException sqlException, String message, String sql) { JDBCExceptionReporter.logExceptions( sqlException, message + " [" + sql + "]" ); return converter.convert( sqlException, message, sql ); }
private static List<SQLException> executeScript(Connection connection, String[] script) throws SQLException { List<SQLException> exceptions = Collections.emptyList(); Statement statement = connection.createStatement(); try { for (String line : script) { log.debug(line); try { statement.executeUpdate(line); if (statement.getWarnings() != null) { JDBCExceptionReporter.logAndClearWarnings(connection); } } catch (SQLException e) { if (exceptions.isEmpty()) { exceptions = new ArrayList<SQLException>(); } exceptions.add(e); } } } finally { statement.close(); } return exceptions; }
public void abortBatch(SQLException sqle) { try { if (batchUpdate!=null) closeStatement(batchUpdate); } catch (SQLException e) { //noncritical, swallow and let the other propagate! JDBCExceptionReporter.logExceptions(e); } finally { batchUpdate=null; batchUpdateSQL=null; } }
private static List<SQLException> executeScript(Connection connection, String[] script) throws SQLException { List<SQLException> exceptions = Collections.emptyList(); Statement statement = connection.createStatement(); try { for (String line : script) { LOG.debug(line); try { statement.executeUpdate(line); if (statement.getWarnings() != null) { JDBCExceptionReporter.logAndClearWarnings(connection); } } catch (SQLException e) { if (exceptions.isEmpty()) { exceptions = new ArrayList<SQLException>(); } exceptions.add(e); } } } finally { statement.close(); } return exceptions; }