@Test public void testaddBatchedPreparedStatementsLog() { final StatementLog log = insert1Log(); final List<String> sqlList = Arrays.asList("st1", "st2", "st3"); final BatchedPreparedStatementsLog batchedLogs = new BatchedPreparedStatementsLog(log.getConnectionUuid(), randomUUID(), System.currentTimeMillis(), "myRaw stmt", sqlList, "myThread", 13, true, 1); repositoryUpdate.addBatchedPreparedStatementsLog(batchedLogs); assertEquals(2, countRowsInTable("statement_log")); assertEquals(3, countRowsInTable("batched_statement_log")); @SuppressWarnings("null") final StatementExecutedLog statementExecutedLog = new StatementExecutedLog(batchedLogs.getLogId(), 123, null, "myexception"); repositoryUpdate.updateLogAfterExecution(statementExecutedLog); repositoryRead.getBatchStatementExecutions(batchedLogs.getLogId(), resultSet -> { { assertTrue(resultSet.next()); assertEquals(0, resultSet.getInt(LogRepositoryConstants.BATCHED_STMT_ORDER)); assertEquals("st1", resultSet.getString(LogRepositoryConstants.FILLED_SQL_COLUMN)); } { assertTrue(resultSet.next()); assertEquals(1, resultSet.getInt(LogRepositoryConstants.BATCHED_STMT_ORDER)); assertEquals("st2", resultSet.getString(LogRepositoryConstants.FILLED_SQL_COLUMN)); } { assertTrue(resultSet.next()); assertEquals(2, resultSet.getInt(LogRepositoryConstants.BATCHED_STMT_ORDER)); assertEquals("st3", resultSet.getString(LogRepositoryConstants.FILLED_SQL_COLUMN)); } assertFalse(resultSet.next()); }); }
@Override public void getBatchStatementExecutions(final UUID logId, final ResultSetAnalyzer analyzer) { String sql = "select batched_stmt_order, filledSql from batched_statement_log where logId=? "; sql += "order by batched_stmt_order"; try (PreparedStatement statement = connectionRead.prepareStatement(sql)) { statement.setObject(1, logId); try (ResultSet resultSet = statement.executeQuery()) { analyzer.analyze(resultSet); } } catch (final SQLException e) { throw new RuntimeException(e); } }
LogRepositoryReadJdbc implements LogRepositoryRead { @Override public void getBatchStatementExecutions(final UUID logId, final ResultSetAnalyzer analyzer) { String sql = "select batched_stmt_order, filledSql from batched_statement_log where logId=? "; sql += "order by batched_stmt_order"; try (PreparedStatement statement = connectionRead.prepareStatement(sql)) { statement.setObject(1, logId); try (ResultSet resultSet = statement.executeQuery()) { analyzer.analyze(resultSet); } } catch (final SQLException e) { throw new RuntimeException(e); } } }
LogRepositoryReadJdbc implements LogRepositoryRead { @Override public void getBatchStatementExecutions(final UUID logId, final ResultSetAnalyzer analyzer) { String sql = "select batched_stmt_order, filledSql from batched_statement_log where logId=? "; sql += "order by batched_stmt_order"; try (PreparedStatement statement = connectionRead.prepareStatement(sql)) { statement.setObject(1, logId); try (ResultSet resultSet = statement.executeQuery()) { analyzer.analyze(resultSet); } } catch (final SQLException e) { throw new RuntimeException(e); } } LogRepositoryReadJdbc(final String dbName); }
LogRepositoryReadJdbc implements LogRepositoryRead { @Override public void getBatchStatementExecutions(final UUID logId, final ResultSetAnalyzer analyzer) { String sql = "select batched_stmt_order, filledSql from batched_statement_log where logId=? "; sql += "order by batched_stmt_order"; try (PreparedStatement statement = connectionRead.prepareStatement(sql)) { statement.setObject(1, logId); try (ResultSet resultSet = statement.executeQuery()) { analyzer.analyze(resultSet); } } catch (final SQLException e) { throw new RuntimeException(e); } } LogRepositoryReadJdbc(final String dbName); @Override void dispose(); @Override void getStatements(final LogSearchCriteria searchCriteria, final ResultSetAnalyzer analyzer,
            final boolean withFilledSql); @Override void getStatementsGroupByRawSQL(final LogSearchCriteria searchCriteria, final ResultSetAnalyzer analyzer); @Override void getStatementsGroupByFilledSQL(final LogSearchCriteria searchCriteria,
            final ResultSetAnalyzer analyzer); @Nullable @Override DetailedViewStatementLog getStatementLog(final long id); @Override int countStatements(); @Override long getTotalExecAndFetchTimeNanos(); @Override long getTotalExecAndFetchTimeNanos(final LogSearchCriteria searchCriteria); @Override void getBatchStatementExecutions(final UUID logId, final ResultSetAnalyzer analyzer); }
LogRepositoryReadJdbc implements LogRepositoryRead { @Override public void getBatchStatementExecutions(final UUID logId, final ResultSetAnalyzer analyzer) { String sql = "select batched_stmt_order, filledSql from batched_statement_log where logId=? "; sql += "order by batched_stmt_order"; try (PreparedStatement statement = connectionRead.prepareStatement(sql)) { statement.setObject(1, logId); try (ResultSet resultSet = statement.executeQuery()) { analyzer.analyze(resultSet); } } catch (final SQLException e) { throw new RuntimeException(e); } } LogRepositoryReadJdbc(final String dbName); @Override void dispose(); @Override void getStatements(final LogSearchCriteria searchCriteria, final ResultSetAnalyzer analyzer,
            final boolean withFilledSql); @Override void getStatementsGroupByRawSQL(final LogSearchCriteria searchCriteria, final ResultSetAnalyzer analyzer); @Override void getStatementsGroupByFilledSQL(final LogSearchCriteria searchCriteria,
            final ResultSetAnalyzer analyzer); @Nullable @Override DetailedViewStatementLog getStatementLog(final long id); @Override int countStatements(); @Override long getTotalExecAndFetchTimeNanos(); @Override long getTotalExecAndFetchTimeNanos(final LogSearchCriteria searchCriteria); @Override void getBatchStatementExecutions(final UUID logId, final ResultSetAnalyzer analyzer);  }