runtime/testapps/src/main/java/com/google/apphosting/loadtesting/allinone/MainServlet.java [897:944]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  private void performCloudSqlAccess(
      String db, int rows, int columns, int len, int timeout, boolean replace, PrintWriter w)
      throws IOException, ServletException {
    String dbUrl = "jdbc:google:mysql://" + db;
    try {
      Class.forName("com.mysql.jdbc.GoogleDriver");
    } catch (ClassNotFoundException e) {
      throw new ServletException("Error loading Google JDBC Driver", e);
    }

    logger.info(String.format("connecting to database %s", dbUrl));
    try (Connection conn = DriverManager.getConnection(dbUrl)) {
      emitf(w, "connected to database %s", dbUrl);
      ResultSet result = conn.createStatement().executeQuery("SELECT 1");
      result.next();
      emit(w, "executed a query, read one result row");
      String tableName = String.format("test%s", Integer.toString(random.nextInt(10000)));
      conn.createStatement().executeUpdate(drop(tableName));
      try {
        conn.createStatement().executeUpdate(create(tableName, columns));
        emitf(w, "created table %s with %d columns", tableName, columns);

        conn.setAutoCommit(false);
        try {
          conn.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
          PreparedStatement s = conn.prepareStatement(replace ? replaceInto(tableName, columns)
              : insertInto(tableName, columns));
          s.setQueryTimeout(timeout);
          for (int i = 0; i < rows; ++i) {
            for (int j = 1; j <= columns; ++j) {
              s.setString(j, createRandomString(len));
            }
            s.addBatch();
          }
          s.executeBatch();
          conn.commit();
        } finally {
          conn.setAutoCommit(true);
        }
        emitf(w, "executed %d %s as a batch", rows, replace ? "REPLACE INTO" : "INSERT INTO");
      } finally {
        conn.createStatement().executeUpdate(drop(tableName));
        emitf(w, "dropped table %s", tableName);
      }
    } catch (SQLException e) {
      throw new ServletException("Error executing SQL", e);
    }
  }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



runtime/testapps/src/main/java/com/google/apphosting/loadtesting/allinone/ee10/MainServlet.java [897:944]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  private void performCloudSqlAccess(
      String db, int rows, int columns, int len, int timeout, boolean replace, PrintWriter w)
      throws IOException, ServletException {
    String dbUrl = "jdbc:google:mysql://" + db;
    try {
      Class.forName("com.mysql.jdbc.GoogleDriver");
    } catch (ClassNotFoundException e) {
      throw new ServletException("Error loading Google JDBC Driver", e);
    }

    logger.info(String.format("connecting to database %s", dbUrl));
    try (Connection conn = DriverManager.getConnection(dbUrl)) {
      emitf(w, "connected to database %s", dbUrl);
      ResultSet result = conn.createStatement().executeQuery("SELECT 1");
      result.next();
      emit(w, "executed a query, read one result row");
      String tableName = String.format("test%s", Integer.toString(random.nextInt(10000)));
      conn.createStatement().executeUpdate(drop(tableName));
      try {
        conn.createStatement().executeUpdate(create(tableName, columns));
        emitf(w, "created table %s with %d columns", tableName, columns);

        conn.setAutoCommit(false);
        try {
          conn.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
          PreparedStatement s = conn.prepareStatement(replace ? replaceInto(tableName, columns)
              : insertInto(tableName, columns));
          s.setQueryTimeout(timeout);
          for (int i = 0; i < rows; ++i) {
            for (int j = 1; j <= columns; ++j) {
              s.setString(j, createRandomString(len));
            }
            s.addBatch();
          }
          s.executeBatch();
          conn.commit();
        } finally {
          conn.setAutoCommit(true);
        }
        emitf(w, "executed %d %s as a batch", rows, replace ? "REPLACE INTO" : "INSERT INTO");
      } finally {
        conn.createStatement().executeUpdate(drop(tableName));
        emitf(w, "dropped table %s", tableName);
      }
    } catch (SQLException e) {
      throw new ServletException("Error executing SQL", e);
    }
  }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



e2etests/testlocalapps/allinone/src/main/java/allinone/MainServlet.java [888:935]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  private void performCloudSqlAccess(
      String db, int rows, int columns, int len, int timeout, boolean replace, PrintWriter w)
      throws IOException, ServletException {
    String dbUrl = "jdbc:google:mysql://" + db;
    try {
      Class.forName("com.mysql.jdbc.GoogleDriver");
    } catch (ClassNotFoundException e) {
      throw new ServletException("Error loading Google JDBC Driver", e);
    }

    logger.info(String.format("connecting to database %s", dbUrl));
    try (Connection conn = DriverManager.getConnection(dbUrl)) {
      emitf(w, "connected to database %s", dbUrl);
      ResultSet result = conn.createStatement().executeQuery("SELECT 1");
      result.next();
      emit(w, "executed a query, read one result row");
      String tableName = String.format("test%s", Integer.toString(random.nextInt(10000)));
      conn.createStatement().executeUpdate(drop(tableName));
      try {
        conn.createStatement().executeUpdate(create(tableName, columns));
        emitf(w, "created table %s with %d columns", tableName, columns);

        conn.setAutoCommit(false);
        try {
          conn.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
          PreparedStatement s = conn.prepareStatement(replace ? replaceInto(tableName, columns)
              : insertInto(tableName, columns));
          s.setQueryTimeout(timeout);
          for (int i = 0; i < rows; ++i) {
            for (int j = 1; j <= columns; ++j) {
              s.setString(j, createRandomString(len));
            }
            s.addBatch();
          }
          s.executeBatch();
          conn.commit();
        } finally {
          conn.setAutoCommit(true);
        }
        emitf(w, "executed %d %s as a batch", rows, replace ? "REPLACE INTO" : "INSERT INTO");
      } finally {
        conn.createStatement().executeUpdate(drop(tableName));
        emitf(w, "dropped table %s", tableName);
      }
    } catch (SQLException e) {
      throw new ServletException("Error executing SQL", e);
    }
  }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



