Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Hive >> mail # user >> can not connect hive through jdbc

Copy link to this message
can not connect hive through jdbc
i use following java code
import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.ResultSet;
  import java.sql.Statement;

  public class DemoHive {
            public static void main(String[] args) throws  Exception {

                String dropSQL="drop table javabloger";
                String createSQL="create table javabloger (key int, value
                String insterSQL="LOAD DATA LOCAL INPATH
'/work/hive/examples/files/kv1.txt' OVERWRITE INTO TABLE javabloger";
                String querySQL="SELECT * FROM hb_dmp_pageview";

                Connection con = DriverManager.getConnection("jdbc:hive2://", "", "");
                Statement stmt = con.createStatement();
       //         stmt.executeQuery(dropSQL);  // 执行删除语句
         //       stmt.executeQuery(createSQL);  // 执行建表语句
        //        stmt.executeQuery(insterSQL);  // 执行插入语句
                ResultSet res = stmt.executeQuery(querySQL);   // 执行查询语句

                  while (res.next()) {
                    System.out.println("Result: key:"+res.getString(1) +"
�>  value:" +res.getString(2));
Exception in thread "main" java.sql.SQLException: Invalid URL: jdbc:hive2://
 at org.apache.hadoop.hive.jdbc.HiveDriver.connect(HiveDriver.java:104)
 at java.sql.DriverManager.getConnection(Unknown Source)
 at java.sql.DriverManager.getConnection(Unknown Source)
 at DemoHive.main(DemoHive.java:17)
and in hive server

# nohup hive --service hiveserver &

# netstat -utlpn|grep 10000
tcp        0      0     *
LISTEN      18430/java