小编adr*_*ian的帖子

使用JDBC从Java连接到Hive

我正在尝试从Java连接到Hive服务器1.我在这个论坛上发现了一个问题,但它对我不起作用.我正在使用此代码:

import java.sql.SQLException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.DriverManager;

public class HiveJdbcClient {
  private static String driverName = "org.apache.hive.jdbc.HiveDriver";

  /**
   * @param args
   * @throws SQLException
   */
  public static void main(String[] args) throws SQLException {
      try {
      Class.forName(driverName);
    } catch (ClassNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      System.exit(1);
    }
    //replace "hive" here with the name of the user the queries should run as
    Connection con = DriverManager.getConnection("jdbc:hive2://localhost:10000/default", "hive", "");
    Statement stmt = con.createStatement();
    String tableName = …
Run Code Online (Sandbox Code Playgroud)

java hadoop hive jdbc

22
推荐指数
2
解决办法
6万
查看次数

标签 统计

hadoop ×1

hive ×1

java ×1

jdbc ×1