Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created 03-23-2017 08:05 AM
String url = "jdbc:hive2://huge-agent02:10000/";
Class.forName(driverName);
conn =(Connection) DriverManager.getConnection(url, "hive", "hive");
when i replace url to zookeeper url (jdbc:hive2://huge-server:2181,huge-agent02:2181,huge-agent01:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2), it can not connected hive,why?
Created 03-23-2017 10:48 AM
Are you passing the driverName as "org.apache.hive.jdbc.HiveDriver" ?
Also when you say with the mentioned url it can not connect .... does it mean that you are getting any error? Or is it getting hung for a long time?
Are the host names resolvable from the host where you are running the code?
Example: (from Client machine)
# telnet huge-server 2181 # telnet huge-agent02 2181 # telnet huge-agent01 2181
.
Created 03-23-2017 10:48 AM
Are you passing the driverName as "org.apache.hive.jdbc.HiveDriver" ?
Also when you say with the mentioned url it can not connect .... does it mean that you are getting any error? Or is it getting hung for a long time?
Are the host names resolvable from the host where you are running the code?
Example: (from Client machine)
# telnet huge-server 2181 # telnet huge-agent02 2181 # telnet huge-agent01 2181
.
Created 03-23-2017 10:50 AM
Exception in thread "main" java.lang.NullPointerException at org.apache.thrift.transport.TSocket.open(TSocket.java:170) at org.apache.thrift.transport.TSaslTransport.open(TSaslTransport.java:266) at org.apache.thrift.transport.TSaslClientTransport.open(TSaslClientTransport.java:37) at org.apache.hive.jdbc.HiveConnection.openTransport(HiveConnection.java:204) at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:176) at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:105) at java.sql.DriverManager.getConnection(DriverManager.java:571) at java.sql.DriverManager.getConnection(DriverManager.java:215) at com.hugedata.hive.HiveJdbcConnect.getConnection(HiveJdbcConnect.java:19) at com.hugedata.hive.HiveTest.main(HiveTest.java:12)
Created 03-23-2017 11:01 AM
I see that some issues were reported with the "hive-jdbc" driver version jar. So can you please clarify which exact version of this jar are you using.
As i am able to run my test successfully at my end (for example i am using "http://repo.hortonworks.com/content/repositories/releases/org/apache/hive/hive-jdbc/1.2.1000.2.5.3.0-37/" )
Created 03-23-2017 11:30 AM
I have uploaded a sample with the "pom.xml" for version check in the github repo: https://github.com/jaysensharma/MiddlewareMagicDemos/tree/master/HDP_Ambari/Hive/HiveJavaClient
Created 03-24-2017 01:09 AM
Created 03-23-2017 10:56 AM
@Jay SenSharma,this is my java code
public class HiveJdbcConnect {
private static String driverName = "org.apache.hive.jdbc.HiveDriver";
private static String url = "jdbc:hive2://huge-server:2181,huge-agent02:2181,huge-agent01:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2";
private static Connection conn = null;
public static Connection getConnection(){
if (conn == null) {
try {
Class.forName(driverName);
conn =(Connection) DriverManager.getConnection(url, "hive", "hive");
} catch (ClassNotFoundException e){
e.printStackTrace();
return null;
} catch (SQLException e) {
e.printStackTrace();
return null;
}
}
return conn;
}
}
Created 03-23-2017 11:08 AM
Try using a different version of "hive-jdbc" driver jar for example i am using "http://repo.hortonworks.com/content/repositories/releases/org/apache/hive/hive-jdbc/1.2.1000.2.5.3.0.../"
Created 03-23-2017 11:32 AM
@Jay SenSharma,Thanks,i try it again.
Created 03-24-2017 01:06 AM
@Jay SenSharma, i change hive-jdbc version to 1.2.1000.2.5.0.0-1245 ,and solved this problem, thank you for your help.