乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      大數(shù)據(jù)IMF傳奇行動(dòng)絕密課程第73課:Spark SQL Thrift Server實(shí)戰(zhàn)

       看風(fēng)景D人 2019-02-24

      通過JDBC/ODBC->Thirft Server->Spark SQL->Hive取代傳統(tǒng)數(shù)據(jù)庫為后臺(tái)的系統(tǒng)
      啟動(dòng)hive:

      hive --service metastore &
      hive

      服務(wù)端:啟動(dòng)thrift服務(wù)端

      ./start-thriftserver.sh --master spark://Master:7077 --hiveconf hive.server2.transport.mode=http --hiveconf hive.server2.thrift.http.path=cliservice

      Java代碼

      /**
       * Java通過JDBC訪問Thrift Server,進(jìn)而訪問Hive,這是企業(yè)級(jí)開發(fā)中最為常見的方式
       */
      public class SparkSQLJDBC2ThriftServer {
      
          /**
           * @param args
           */
          public static void main(String[] args) {
      
              Connection conn = null;
              ResultSet rs = null;
              String sql = "select * from people where age = ?";
              try {
                  Class.forName("org.apache.hive.jdbc.HiveDriver");
                  conn = DriverManager.getConnection("jdbc:hive2://Master:10001/default?"     //10001為thrift默認(rèn)端口,default為hive'中的庫
                          + "hive.server2.transport.mode=http;hive.server2.thrift.http.path=cliservice",
                          "root","");
                  PreparedStatement stmt = conn.prepareStatement(sql);
                  stmt.setInt(1, 30);
                  rs = stmt.executeQuery();
                  while(rs.next()){
                      System.out.println(rs.getString(1)); //數(shù)據(jù)應(yīng)保存成parquet
                  }
              } catch (ClassNotFoundException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              } catch (SQLException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              } finally {
                  try {
                      rs.close();
                      conn.close();
                  } catch (SQLException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                  }
              }
          }
      }

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多