@Test public void testaddBatchedNonPreparedStatementsLog() { final StatementLog log = insert1Log(); final List<String> sqlList = Arrays.asList("st1", "st2", "st3"); final BatchedNonPreparedStatementsLog batchedLogs = new BatchedNonPreparedStatementsLog(log.getConnectionUuid(), randomUUID(), System.currentTimeMillis(), sqlList, "myThread", 13, true, 1); repositoryUpdate.addBatchedNonPreparedStatementsLog(batchedLogs); assertEquals(2, countRowsInTable("statement_log")); assertEquals(3, countRowsInTable("batched_statement_log")); }
@Override public synchronized void addBatchedNonPreparedStatementsLog(final BatchedNonPreparedStatementsLog log) { LOGGER.debug("addBatchedNonPreparedStatementsLog:{}", log); try { int i = 1; addStatementLog.setObject(i++, log.getLogId()); addStatementLog.setTimestamp(i++, new Timestamp(log.getTimestamp())); addStatementLog.setInt(i++, log.getStatementType().getId()); addStatementLog.setString(i++, "(" + log.getSqlList().size() + " batched statements, click for details)"); addStatementLog.setString(i++, "(click for details)"); addStatementLog.setString(i++, log.getThreadName()); addStatementLog.setObject(i++, log.getConnectionUuid()); addStatementLog.setInt(i++, log.getTimeout()); addStatementLog.setBoolean(i++, log.isAutoCommit()); addStatementLog.setInt(i++, log.getTransactionIsolation()); addStatementLog.executeUpdate(); addBatchedStatementLog.setObject(1, log.getLogId()); for (int j = 0; j < log.getSqlList().size(); j++) { addBatchedStatementLog.setInt(2, j); addBatchedStatementLog.setString(3, log.getSqlList().get(j)); addBatchedStatementLog.addBatch(); } addBatchedStatementLog.executeBatch(); } catch (final SQLException e) { throw new RuntimeException(e); } lastModificationTime = System.currentTimeMillis(); }
LogRepositoryUpdateJdbc implements LogRepositoryUpdate { @Override public synchronized void addBatchedNonPreparedStatementsLog(final BatchedNonPreparedStatementsLog log) { LOGGER.debug("addBatchedNonPreparedStatementsLog:{}", log); try { int i = 1; addStatementLog.setObject(i++, log.getLogId()); addStatementLog.setTimestamp(i++, new Timestamp(log.getTimestamp())); addStatementLog.setInt(i++, log.getStatementType().getId()); addStatementLog.setString(i++, "(" + log.getSqlList().size() + " batched statements, click for details)"); addStatementLog.setString(i++, "(click for details)"); addStatementLog.setString(i++, log.getThreadName()); addStatementLog.setObject(i++, log.getConnectionUuid()); addStatementLog.setInt(i++, log.getTimeout()); addStatementLog.setBoolean(i++, log.isAutoCommit()); addStatementLog.setInt(i++, log.getTransactionIsolation()); addStatementLog.executeUpdate(); addBatchedStatementLog.setObject(1, log.getLogId()); for (int j = 0; j < log.getSqlList().size(); j++) { addBatchedStatementLog.setInt(2, j); addBatchedStatementLog.setString(3, log.getSqlList().get(j)); addBatchedStatementLog.addBatch(); } addBatchedStatementLog.executeBatch(); } catch (final SQLException e) { throw new RuntimeException(e); } lastModificationTime = System.currentTimeMillis(); } }
LogRepositoryUpdateJdbc implements LogRepositoryUpdate { @Override public synchronized void addBatchedNonPreparedStatementsLog(final BatchedNonPreparedStatementsLog log) { LOGGER.debug("addBatchedNonPreparedStatementsLog:{}", log); try { int i = 1; addStatementLog.setObject(i++, log.getLogId()); addStatementLog.setTimestamp(i++, new Timestamp(log.getTimestamp())); addStatementLog.setInt(i++, log.getStatementType().getId()); addStatementLog.setString(i++, "(" + log.getSqlList().size() + " batched statements, click for details)"); addStatementLog.setString(i++, "(click for details)"); addStatementLog.setString(i++, log.getThreadName()); addStatementLog.setObject(i++, log.getConnectionUuid()); addStatementLog.setInt(i++, log.getTimeout()); addStatementLog.setBoolean(i++, log.isAutoCommit()); addStatementLog.setInt(i++, log.getTransactionIsolation()); addStatementLog.executeUpdate(); addBatchedStatementLog.setObject(1, log.getLogId()); for (int j = 0; j < log.getSqlList().size(); j++) { addBatchedStatementLog.setInt(2, j); addBatchedStatementLog.setString(3, log.getSqlList().get(j)); addBatchedStatementLog.addBatch(); } addBatchedStatementLog.executeBatch(); } catch (final SQLException e) { throw new RuntimeException(e); } lastModificationTime = System.currentTimeMillis(); } LogRepositoryUpdateJdbc(final String name); }
LogRepositoryUpdateJdbc implements LogRepositoryUpdate { @Override public synchronized void addBatchedNonPreparedStatementsLog(final BatchedNonPreparedStatementsLog log) { LOGGER.debug("addBatchedNonPreparedStatementsLog:{}", log); try { int i = 1; addStatementLog.setObject(i++, log.getLogId()); addStatementLog.setTimestamp(i++, new Timestamp(log.getTimestamp())); addStatementLog.setInt(i++, log.getStatementType().getId()); addStatementLog.setString(i++, "(" + log.getSqlList().size() + " batched statements, click for details)"); addStatementLog.setString(i++, "(click for details)"); addStatementLog.setString(i++, log.getThreadName()); addStatementLog.setObject(i++, log.getConnectionUuid()); addStatementLog.setInt(i++, log.getTimeout()); addStatementLog.setBoolean(i++, log.isAutoCommit()); addStatementLog.setInt(i++, log.getTransactionIsolation()); addStatementLog.executeUpdate(); addBatchedStatementLog.setObject(1, log.getLogId()); for (int j = 0; j < log.getSqlList().size(); j++) { addBatchedStatementLog.setInt(2, j); addBatchedStatementLog.setString(3, log.getSqlList().get(j)); addBatchedStatementLog.addBatch(); } addBatchedStatementLog.executeBatch(); } catch (final SQLException e) { throw new RuntimeException(e); } lastModificationTime = System.currentTimeMillis(); } LogRepositoryUpdateJdbc(final String name); @Override void dispose(); @Override synchronized void addStatementLog(final StatementLog log); @Override synchronized void addStatementFullyExecutedLog(final Collection<StatementFullyExecutedLog> logs); @Override synchronized void updateLogAfterExecution(final StatementExecutedLog log); @Override synchronized void updateLogWithResultSetLog(final ResultSetLog log); @Override synchronized void addBatchedPreparedStatementsLog(final BatchedPreparedStatementsLog log); @Override synchronized void addBatchedNonPreparedStatementsLog(final BatchedNonPreparedStatementsLog log); @Override synchronized void addConnection(final ConnectionInfo connectionInfo); @Override synchronized void addTxCompletionLog(final TxCompleteLog log); @Override void clear(); @Override void deleteStatementLog(final long... logIds); void deleteOldRowsIfTooMany(); @Override synchronized long getLastModificationTime(); @Override void setLastLostMessageTime(@Nullable final Long timestamp); @Override @Nullable Long getLastLostMessageTime(); }
LogRepositoryUpdateJdbc implements LogRepositoryUpdate { @Override public synchronized void addBatchedNonPreparedStatementsLog(final BatchedNonPreparedStatementsLog log) { LOGGER.debug("addBatchedNonPreparedStatementsLog:{}", log); try { int i = 1; addStatementLog.setObject(i++, log.getLogId()); addStatementLog.setTimestamp(i++, new Timestamp(log.getTimestamp())); addStatementLog.setInt(i++, log.getStatementType().getId()); addStatementLog.setString(i++, "(" + log.getSqlList().size() + " batched statements, click for details)"); addStatementLog.setString(i++, "(click for details)"); addStatementLog.setString(i++, log.getThreadName()); addStatementLog.setObject(i++, log.getConnectionUuid()); addStatementLog.setInt(i++, log.getTimeout()); addStatementLog.setBoolean(i++, log.isAutoCommit()); addStatementLog.setInt(i++, log.getTransactionIsolation()); addStatementLog.executeUpdate(); addBatchedStatementLog.setObject(1, log.getLogId()); for (int j = 0; j < log.getSqlList().size(); j++) { addBatchedStatementLog.setInt(2, j); addBatchedStatementLog.setString(3, log.getSqlList().get(j)); addBatchedStatementLog.addBatch(); } addBatchedStatementLog.executeBatch(); } catch (final SQLException e) { throw new RuntimeException(e); } lastModificationTime = System.currentTimeMillis(); } LogRepositoryUpdateJdbc(final String name); @Override void dispose(); @Override synchronized void addStatementLog(final StatementLog log); @Override synchronized void addStatementFullyExecutedLog(final Collection<StatementFullyExecutedLog> logs); @Override synchronized void updateLogAfterExecution(final StatementExecutedLog log); @Override synchronized void updateLogWithResultSetLog(final ResultSetLog log); @Override synchronized void addBatchedPreparedStatementsLog(final BatchedPreparedStatementsLog log); @Override synchronized void addBatchedNonPreparedStatementsLog(final BatchedNonPreparedStatementsLog log); @Override synchronized void addConnection(final ConnectionInfo connectionInfo); @Override synchronized void addTxCompletionLog(final TxCompleteLog log); @Override void clear(); @Override void deleteStatementLog(final long... logIds); void deleteOldRowsIfTooMany(); @Override synchronized long getLastModificationTime(); @Override void setLastLostMessageTime(@Nullable final Long timestamp); @Override @Nullable Long getLastLostMessageTime(); static final int SCHEMA_VERSION; }