get Hive Connection - Java java.sql

Java examples for java.sql:Connection

Description

get Hive Connection

Demo Code


//package com.java2s;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Main {
    private static Connection connToHive = null;

    public static Connection getHiveConn() throws SQLException,
            ClassNotFoundException {
        if (connToHive == null) {
            Class.forName("org.apache.hadoop.hive.jdbc.HiveDriver");
            connToHive = DriverManager.getConnection(
                    "jdbc:hive://master/default", "hive", "guotao");
        }/*ww w .  ja v  a2 s. co m*/
        return connToHive;
    }
}

Related Tutorials