/** * Creates a new context with the given debugging description and the expected runtime. * * @param description a provider for a description used for debugging purposes * @param expectedDuration the expected duration of the whole batch operation */ public BatchContext(Supplier<String> description, Duration expectedDuration) { this.op = new Operation(description, expectedDuration); }
@Override public int executeUpdate(String sql) throws SQLException { if (Databases.LOG.isFINE()) { Databases.LOG.FINE(sql); } Watch w = Watch.start(); try (Operation op = new Operation(() -> sql, Duration.ofSeconds(30))) { return stmt.executeUpdate(sql); } finally { updateStatistics(sql, w); } }
@Override public ResultSet executeQuery(String sql) throws SQLException { if (Databases.LOG.isFINE()) { Databases.LOG.FINE(sql); } Watch w = Watch.start(); try (Operation op = new Operation(() -> sql, Duration.ofSeconds(30))) { return delegate.executeQuery(sql); } finally { updateStatistics(sql, w); } }
@Override public ResultSet executeQuery(String sql) throws SQLException { if (Databases.LOG.isFINE()) { Databases.LOG.FINE(sql); } Watch w = Watch.start(); try (Operation op = new Operation(() -> sql, Duration.ofSeconds(30))) { return stmt.executeQuery(sql); } finally { updateStatistics(sql, w); } }
@Override public int executeUpdate(String sql, int[] columnIndexes) throws SQLException { if (Databases.LOG.isFINE()) { Databases.LOG.FINE(sql); } Watch w = Watch.start(); try (Operation op = new Operation(() -> sql, Duration.ofSeconds(30))) { return stmt.executeUpdate(sql, columnIndexes); } finally { updateStatistics(sql, w); } }
@Override public boolean execute() throws SQLException { if (Databases.LOG.isFINE()) { Databases.LOG.FINE(preparedSQL); } Watch w = Watch.start(); try (Operation op = new Operation(() -> preparedSQL, Duration.ofSeconds(30))) { return delegate.execute(); } finally { updateStatistics(preparedSQL, w); } }
@Override public boolean execute(String sql, int autoGeneratedKeys) throws SQLException { if (Databases.LOG.isFINE()) { Databases.LOG.FINE(sql); } Watch w = Watch.start(); try (Operation op = new Operation(() -> sql, Duration.ofSeconds(30))) { return delegate.execute(sql, autoGeneratedKeys); } finally { updateStatistics(sql, w); } }
@Override public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException { if (Databases.LOG.isFINE()) { Databases.LOG.FINE(sql); } Watch w = Watch.start(); try (Operation op = new Operation(() -> sql, Duration.ofSeconds(30))) { return stmt.executeUpdate(sql, autoGeneratedKeys); } finally { updateStatistics(sql, w); } }
@Override public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException { if (Databases.LOG.isFINE()) { Databases.LOG.FINE(sql); } Watch w = Watch.start(); try (Operation op = new Operation(() -> sql, Duration.ofSeconds(30))) { return delegate.executeUpdate(sql, autoGeneratedKeys); } finally { updateStatistics(sql, w); } }
@Override public int executeUpdate(String sql, int[] columnIndexes) throws SQLException { if (Databases.LOG.isFINE()) { Databases.LOG.FINE(sql); } Watch w = Watch.start(); try (Operation op = new Operation(() -> sql, Duration.ofSeconds(30))) { return delegate.executeUpdate(sql, columnIndexes); } finally { updateStatistics(sql, w); } }
@Override public int executeUpdate(String sql, String[] columnNames) throws SQLException { if (Databases.LOG.isFINE()) { Databases.LOG.FINE(sql); } Watch w = Watch.start(); try (Operation op = new Operation(() -> sql, Duration.ofSeconds(30))) { return delegate.executeUpdate(sql, columnNames); } finally { updateStatistics(sql, w); } }
@Override public boolean execute(String sql, int[] columnIndexes) throws SQLException { if (Databases.LOG.isFINE()) { Databases.LOG.FINE(sql); } Watch w = Watch.start(); try (Operation op = new Operation(() -> sql, Duration.ofSeconds(30))) { return delegate.execute(sql, columnIndexes); } finally { updateStatistics(sql, w); } }
@Override public boolean execute(String sql) throws SQLException { if (Databases.LOG.isFINE()) { Databases.LOG.FINE(sql); } Watch w = Watch.start(); try (Operation op = new Operation(() -> sql, Duration.ofSeconds(30))) { return stmt.execute(sql); } finally { updateStatistics(sql, w); } }
@Override public boolean execute(String sql, String[] columnNames) throws SQLException { if (Databases.LOG.isFINE()) { Databases.LOG.FINE(sql); } Watch w = Watch.start(); try (Operation op = new Operation(() -> sql, Duration.ofSeconds(30))) { return stmt.execute(sql, columnNames); } finally { updateStatistics(sql, w); } }
@Override public int executeUpdate(String sql) throws SQLException { if (Databases.LOG.isFINE()) { Databases.LOG.FINE(sql); } Watch w = Watch.start(); try (Operation op = new Operation(() -> sql, Duration.ofSeconds(30))) { return delegate.executeUpdate(sql); } finally { updateStatistics(sql, w); } }
@Override public int executeUpdate() throws SQLException { if (Databases.LOG.isFINE()) { Databases.LOG.FINE(preparedSQL); } Watch w = Watch.start(); try (Operation op = new Operation(() -> preparedSQL, Duration.ofSeconds(30))) { return delegate.executeUpdate(); } finally { updateStatistics(preparedSQL, w); } }
@Override public boolean execute(String sql, String[] columnNames) throws SQLException { if (Databases.LOG.isFINE()) { Databases.LOG.FINE(sql); } Watch w = Watch.start(); try (Operation op = new Operation(() -> sql, Duration.ofSeconds(30))) { return delegate.execute(sql, columnNames); } finally { updateStatistics(sql, w); } }
@Override public boolean execute(String sql, int[] columnIndexes) throws SQLException { if (Databases.LOG.isFINE()) { Databases.LOG.FINE(sql); } Watch w = Watch.start(); try (Operation op = new Operation(() -> sql, Duration.ofSeconds(30))) { return stmt.execute(sql, columnIndexes); } finally { updateStatistics(sql, w); } }
@Override public ResultSet executeQuery() throws SQLException { if (Databases.LOG.isFINE()) { Databases.LOG.FINE(preparedSQL); } Watch w = Watch.start(); try (Operation op = new Operation(() -> preparedSQL, Duration.ofSeconds(30))) { return delegate.executeQuery(); } finally { updateStatistics(preparedSQL, w); } }
@Override public boolean execute(String sql) throws SQLException { if (Databases.LOG.isFINE()) { Databases.LOG.FINE(sql); } Watch w = Watch.start(); try (Operation op = new Operation(() -> sql, Duration.ofSeconds(30))) { return delegate.execute(sql); } finally { updateStatistics(sql, w); } }