I need to connect to Hive from Java program via JDBC. I searched google and found numerous guides and examples like this: HiveServer2 clients
However, I could not find the JDBC driver itself (jar file) anywhere. There seem to be a jar file for download from Cloudera, but it requires registration.
Does anyone know where to get the plain Apache Hive JDBC driver itself ?
Using the Apache driver is fine if your program runs on a host with all the Hadoop libs already installed. Otherwise you will have to drag a smorgasbord of dependencies i.e.
Packaging all these dependencies in your own JAR will probably result in a massive, cluttered piece of shoftware (God, how Maven is misused nowadays). Plus, you may have compatibility issue because newer clients are not compatible with older servers. "Not compatible" meaning "unable to initialize connection with Thrift server".
For a standalone install the Cloudera driver may be a good solution - registration just means leaving one of your "junk" e-mails to get a couple of marketing messages (and you can un-subscribe then). Although I admit I've never used it on a non-Cloudera cluster.
Add this dependency to your Maven pom:
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-jdbc</artifactId>
<version>2.0.0</version>
</dependency>
The jar can be downloaded from: http://central.maven.org/maven2/org/apache/hive/hive-jdbc/2.0.0/hive-jdbc-2.0.0.jar
Complete list of versions: http://www.mvnrepository.com/artifact/org.apache.hive/hive-jdbc
You can download an uber jar here:
https://github.com/timveil/hive-jdbc-uber-jar/releases
Works straightaway.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With