protected Connection refreshDbConnection()

in DeliveryApi/ApiHandlers/src/com/ilmlf/delivery/api/handlers/service/SlotService.java [249:271]


  protected Connection refreshDbConnection() {
    Connection connection = this.con;

    try {
      if (connection == null || !connection.isValid(1)) {
        logger.info("Retrying database connection");
        try {
          Thread.sleep(BACKOFF_TIME_MILLI);
          connection = this.dbUtil.createConnectionViaIamAuth(DB_USER, DB_ENDPOINT, DB_REGION, DB_PORT);
        } catch (InterruptedException e) {
          logger.error(e.getMessage(), e);
          throw new RuntimeException("There was a problem sleeping the thread while creating a connection to the DB");
        }
      }

    } catch (SQLException e) {
      logger.error(e.getMessage(), e);
      throw new RuntimeException("There was a problem refreshing the database connection "
        + "due to an error while checking validity");
    }

    return connection;
  }