Connecting to HiveServer2 using JDBC


#1

Could anyone help connecting to HiveSever2 using JDBC? It seems that I’m able to add the correct dependenciees in my maven pom.
My code:
public class HiveJdbcClient {

private static String driverName = "org.apache.hive.jdbc.HiveDriver";
private static String HIVE_SERVER2 = "jdbc:hive2://nn01.itversity.com:2181,nn02.itversity.com:2181,rm01.itversity.com:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2";


public static void main(String[] args) {

    try {
        Class.forName(driverName);

        
        Connection con = DriverManager.getConnection(HIVE_SERVER2, "userxxxx","passyyyy");

        System.out.println("Got the connection");


    } catch (Exception e) {
        e.printStackTrace();
    } 

}

}

maven dependencies:

    <dependency>
        <groupId>org.apache.hive</groupId>
        <artifactId>hive-exec</artifactId>
        <version>1.2.0</version>
    </dependency>


    <dependency>
        <groupId>org.apache.hive</groupId>
        <artifactId>hive-jdbc</artifactId>
        <version>1.2.1000.2.5.0.0-1245</version>
    </dependency>


    <dependency>
        <groupId>org.apache.hadoop</groupId>
        <artifactId>hadoop-common</artifactId>
        <version>2.5.0</version>
    </dependency>


    <dependency>
        <groupId>org.apache.hive</groupId>
        <artifactId>hive-service</artifactId>
        <version>0.11.0</version>
    </dependency>


   <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpcore</artifactId>
        <version>4.4.6</version>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.5.2</version>
        <scope>runtime</scope>
    </dependency>

</dependencies>