コード例 #1
0
  protected Connection getConnect() throws SQLException, ClassNotFoundException {
    HiveUtil.verifyDriver();

    if (connect == null) {
      String url =
          HiveUtil.getUrl(hiveConfig.getHost(), hiveConfig.getPort(), hiveConfig.getDatabase());
      connect =
          DriverManager.getConnection(url, hiveConfig.getUserName(), hiveConfig.getPassword());
    }
    return connect;
  }
コード例 #2
0
  protected void load() throws ClassNotFoundException, SQLException {
    Statement queryStmt = getConnect().createStatement();
    // id long, imsi string, isdn string, imei string, operatorCode string, operatorName string,
    // deviceBrand string, deviceModel string
    String sql =
        "select id, imsi, isdn, imei, operatorCode, operatorName, deviceBrand, deviceModel from "
            + hiveConfig.getTableName();
    ResultSet rs = queryStmt.executeQuery(sql);

    if (!rs.first()) {
      logger.warn("No Record for customer enriched info.");
      rs.close();
      return;
    }

    List<SingleRecord> customerInfoList = Lists.newArrayList();
    while (rs.next()) {
      int columnIndex = 0;
      String id = rs.getString(columnIndex++);
      String imsi = rs.getString(columnIndex++);
      String isdn = rs.getString(columnIndex++);
      String imei = rs.getString(columnIndex++);
      String operatorCode = rs.getString(columnIndex++);
      String operatorName = rs.getString(columnIndex++);
      String deviceBrand = rs.getString(columnIndex++);
      String deviceModel = rs.getString(columnIndex++);

      SingleRecord record =
          new SingleRecord(
              id, imsi, isdn, imei, operatorCode, operatorName, deviceBrand, deviceModel);
      customerInfoList.add(record);
    }

    customerInfoArray = customerInfoList.toArray(new SingleRecord[0]);
  }