我是Sandbox HDP的新手,我尝试使用JDBC连接到Hive,我使用了Ambari提供的JDBC URL,这是我的代码:
private static String driverName = "org.apache.hadoop.hive.jdbc.HiveDriver";
public static void main(String[] args) throws SQLException {
try {
Class.forName(driverName);
} catch (ClassNotFoundException e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
Connection con = DriverManager.getConnection(
"jdbc:hive2://sandbox-hdp.hortonworks.com:2181/default;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2");
}
但是,我遇到了这个错误:
Exception in thread "main" java.sql.SQLException: Invalid URL: jdbc:hive2://sandbox-hdp.hortonworks.com:2181/default;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2
at org.apache.hadoop.hive.jdbc.HiveConnection.<init>(HiveConnection.java:86)
at org.apache.hadoop.hive.jdbc.HiveDriver.connect(HiveDriver.java:106)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at Hive2.main(Hive2.java:21)
如果有人可以帮助解决此问题,将不胜感激