cloud-sql/mysql/servlet/src/main/java/com/example/cloudsql/ConnectionPoolContextListener.java [44:67]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  public void contextInitialized(ServletContextEvent event) {
    // This function is called when the application starts and will safely create a connection pool
    // that can be used to connect to.
    ServletContext servletContext = event.getServletContext();
    DataSource pool = (DataSource) servletContext.getAttribute("my-pool");
    if (pool == null) {
      if (System.getenv("INSTANCE_HOST") != null) {
        pool = TcpConnectionPoolFactory.createConnectionPool();
      } else if (System.getenv("DB_IAM_USER") != null) {
        pool = ConnectorIamAuthnConnectionPoolFactory.createConnectionPool();
      } else {
        pool = ConnectorConnectionPoolFactory.createConnectionPool();
      }
      servletContext.setAttribute("my-pool", pool);
    }
    try {
      Utils.createTable(pool);
    } catch (SQLException ex) {
      throw new RuntimeException(
          "Unable to verify table schema. Please double check the steps"
              + "in the README and try again.",
          ex);
    }
  }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



cloud-sql/postgres/servlet/src/main/java/com/example/cloudsql/ConnectionPoolContextListener.java [44:67]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  public void contextInitialized(ServletContextEvent event) {
    // This function is called when the application starts and will safely create a connection pool
    // that can be used to connect to.
    ServletContext servletContext = event.getServletContext();
    DataSource pool = (DataSource) servletContext.getAttribute("my-pool");
    if (pool == null) {
      if (System.getenv("INSTANCE_HOST") != null) {
        pool = TcpConnectionPoolFactory.createConnectionPool();
      } else if (System.getenv("DB_IAM_USER") != null) {
        pool = ConnectorIamAuthnConnectionPoolFactory.createConnectionPool();
      } else {
        pool = ConnectorConnectionPoolFactory.createConnectionPool();
      }
      servletContext.setAttribute("my-pool", pool);
    }
    try {
      Utils.createTable(pool);
    } catch (SQLException ex) {
      throw new RuntimeException(
          "Unable to verify table schema. Please double check the steps"
              + "in the README and try again.",
          ex);
    }
  }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



