连接到hiveserver2时出错 蜂巢服务器2& hadoop在我的本地机器上启动并运行
尝试以下代码
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
Connection con = DriverManager.getConnection("jdbc:odbc://dsn=hello;driver=Microsoft Hive ODBC Driver;Host=127.0.0.1;Port=5000;HiveServerType=2;AuthMech=0");
Statement stmt = con.createStatement();
ResultSet res = stmt.executeQuery("SHOW TABLES");
ResultSetMetaData rsmdData = res.getMetaData();
int count = rsmdData.getColumnCount();
while (res.next()) {
for (int i = 1; i <= count; i++) {
System.out.print(res.getString(i) + "\t");
}
System.out.println();
}
我收到以下错误
Exception in thread "main" java.sql.SQLException: [Microsoft][HiveODBC] (34) Error from Hive: ETIMEDOUT.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcConnection.initialize(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at hivedev.HiveODBC.main(HiveODBC.java:20)
但是我可以通过beeline cli连接