/** * Close the statement. */ protected void closeStatement(StatementProxy stmt) throws SQLException { stmt.wrapped().close(); }
/** * Returns the proxy of {@link Statement}. */ protected StatementProxy proxyOfStatement(Statement stmt) { return new StatementProxy(this, stmt, statementStackTrace); }
@Override public final int executeUpdate(String sql, int[] columnIndexes) throws SQLException { try { beginExecute(sql); return stmt.executeUpdate(sql, columnIndexes); }catch (SQLException e) { throw handleSQLException(e); }finally{ endExecute(); } }
@Override public final ResultSet executeQuery(String sql) throws SQLException { try { beginExecute(sql); return proxyOfResultSet(stmt.executeQuery(sql)); }catch (SQLException e) { throw handleSQLException(e); }finally{ endExecute(); } }
public void reset() { for(int i=0;i<length;i++) { StatementProxy stmt = array[i]; if(null != stmt) { try { log.warn("A potential statement leak detected, force to close it, sql ({}), stack trace -> \n{}", stmt.getLastExecutingSql(), new StackTraceStringBuilder(null, stmt.getStackTraceOnOpen()).toString(Pool.FRAMEWORK_PACKAGE)); closeStatementOnly(stmt); } catch (SQLException e) { } finally { array[i] = null; } } } if(array.length > MAX_CAPACITY) { array = new StatementProxy[DEFAULT_CAPACITY]; } this.length = 0; } }
if(config.getVerySlowSqlThreshold() > 0 && stmt.getLastExecutingDurationMs() >= config.getVerySlowSqlThreshold()) { ss = new SlowSql(stmt.getLastExecutingSql(), stmt.getLastExecutingDurationMs(), conn.getStackTraceOnOpen()); }else if(config.getSlowSqlThreshold() > 0 && stmt.getLastExecutingDurationMs() >= config.getSlowSqlThreshold()) { ss = new SlowSql(stmt.getLastExecutingSql(), stmt.getLastExecutingDurationMs(), conn.getStackTraceOnOpen());
@Override public final ResultSet getResultSet() throws SQLException { return proxyOfResultSet(super.getResultSet()); }
@Override public final void addBatch(String sql) throws SQLException { this.lastExecutingSql = sql; try { super.addBatch(sql); }catch (SQLException e) { throw handleSQLException(e); } }
@Override public final ResultSet getGeneratedKeys() throws SQLException { return proxyOfResultSet(super.getGeneratedKeys()); }
@Override public final int executeUpdate(String sql, String[] columnNames) throws SQLException { try { beginExecute(sql); return stmt.executeUpdate(sql, columnNames); }catch (SQLException e) { throw handleSQLException(e); }finally{ endExecute(); } }
void closeStatementOnly(StatementProxy proxy) throws SQLException { try{ proxy.wrapped().close(); successCloseStatement(proxy); }catch(SQLException e) { errorCloseStatement(proxy, e); throw e; } }
@Override public final int executeUpdate(String sql) throws SQLException { try { beginExecute(sql); return stmt.executeUpdate(sql); }catch(SQLException e) { throw handleSQLException(e); }finally{ endExecute(); } }
@Override public final boolean execute(String sql, String[] columnNames) throws SQLException { try { beginExecute(sql); return stmt.execute(sql, columnNames); }catch (SQLException e) { throw handleSQLException(e); }finally{ endExecute(); } }
@Override public final boolean execute(String sql, int autoGeneratedKeys) throws SQLException { try { beginExecute(sql); return stmt.execute(sql, autoGeneratedKeys); }catch (SQLException e) { throw handleSQLException(e); }finally{ endExecute(); } }
@Override public final boolean execute(String sql, int[] columnIndexes) throws SQLException { try { beginExecute(sql); return stmt.execute(sql, columnIndexes); }catch (SQLException e) { throw handleSQLException(e); }finally{ endExecute(); } }
@Override public final boolean execute(String sql) throws SQLException { try { beginExecute(sql); return stmt.execute(sql); }catch (SQLException e) { throw handleSQLException(e); }finally{ endExecute(); } }
@Override public final int[] executeBatch() throws SQLException { try { beginExecute(null); return stmt.executeBatch(); }catch (SQLException e) { throw handleSQLException(e); }finally{ endExecute(); } }
@Override public final int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException { try { beginExecute(sql); return stmt.executeUpdate(sql, autoGeneratedKeys); }catch (SQLException e) { throw handleSQLException(e); }finally{ endExecute(); } }