Esempio n. 1
0
 @Override
 public void traceMarker() throws Exception {
   PreparedStatement preparedStatement =
       connection.prepareStatement("select * from employee where name like ?");
   try {
     // pull back 0 records
     preparedStatement.setString(1, "nomatch%");
     preparedStatement.execute();
     ResultSet rs = preparedStatement.getResultSet();
     rs.next();
     // disable plugin and re-execute same prepared statement
     services.setPluginEnabled(PLUGIN_ID, false);
     preparedStatement.setString(1, "john%");
     preparedStatement.execute();
     // re-enable plugin and iterate over 1 record to make sure that these records are
     // not attributed to the previous execution
     services.setPluginEnabled(PLUGIN_ID, true);
     rs = preparedStatement.getResultSet();
     rs.next();
     rs.next();
     rs.next();
     rs.next();
   } finally {
     preparedStatement.close();
   }
 }
Esempio n. 2
0
  public static class ExecuteStatementDisableReEnableMidIterating
      implements AppUnderTest, TraceMarker {
    private static final AppUnderTestServices services = AppUnderTestServices.get();
    private Connection connection;

    @Override
    public void executeApp() throws Exception {
      connection = createConnection();
      try {
        traceMarker();
      } finally {
        closeConnection(connection);
      }
    }

    @Override
    public void traceMarker() throws Exception {
      PreparedStatement preparedStatement =
          connection.prepareStatement("select * from employee where name like ?");
      try {
        // pull back 0 records
        preparedStatement.setString(1, "nomatch%");
        preparedStatement.execute();
        ResultSet rs = preparedStatement.getResultSet();
        rs.next();
        // disable plugin and re-execute same prepared statement
        services.setPluginEnabled(PLUGIN_ID, false);
        preparedStatement.setString(1, "john%");
        preparedStatement.execute();
        // re-enable plugin and iterate over 1 record to make sure that these records are
        // not attributed to the previous execution
        services.setPluginEnabled(PLUGIN_ID, true);
        rs = preparedStatement.getResultSet();
        rs.next();
        rs.next();
        rs.next();
        rs.next();
      } finally {
        preparedStatement.close();
      }
    }
  }