java - jdbc connectivity error with hive2 -
i trying test connectivity hive2 using jdbc. getting authentication failled error credentials correct.
the error is:
java -cp .:/users/apps/ewbeiu/wbeeappp/hivejdbcclient/* hivejdbcclient slf4j: failed load class "org.slf4j.impl.staticloggerbinder". slf4j: defaulting no-operation (nop) logger implementation slf4j: see http://www.slf4j.org/codes.html#staticloggerbinder further details. not able connect database pls check settings java.sql.sqlexception: not open connection jdbc:hive2://edbd.corp.com:10000/wbe: peer indicated failure: error validating login exception in thread "main" java.lang.nullpointerexception @ hivejdbcclient.executequery(hivejdbcclient.java:49) @ hivejdbcclient.main(hivejdbcclient.java:58)
the complete code folllows
import java.sql.*; import java.text.parseexception; public class hivejdbcclient { private static final string driver_name = "org.apache.hive.jdbc.hivedriver"; private static final string hive_url = "jdbc:hive2://edabd.xyz.com:10000/wbe"; private static final string hive_uname = "xyz"; private static final string hive_pwd = "pec7"; private static connection con; private hivejdbcclient() { } public static connection getconnection() { try { if (con == null) { synchronized (hivejdbcclient.class) { if (con == null) { class.forname(driver_name); con = drivermanager.getconnection(hive_url, hive_uname, hive_pwd); system.out .println("successfuly connected database...!"); } }// end of synchronized block. }// end of if block. } catch (sqlexception e) { system.out .println("not able connect database pls check settings \n" + e); } catch (classnotfoundexception e) { system.out .println("not able connect database pls check settings \n" + e); }// end of try-catch block. return con; }// end of getconnection() method. public static resultset executequery(string sql) { resultset set = null; try { if (sql != null) { set = getconnection().createstatement().executequery(sql); } } catch (sqlexception e) { system.out.println("error while executing query " + e); }// end of try-catch block. return set; }// end of executequery() method. public static void main(string[] args) throws parseexception, sqlexception { resultset res = executequery("show tables;"); while (res.next()) { system.out.println(string.valueof(res.getstring(1)) // + string.valueof(res.getfloat(2)) + '\t' // + string.valueof(res.getstring(3)) ); } } } > drivers in classpath follows: > > httpclient-4.2.5.jar commons-codec-1.4.jar httpcore-4.2.5.jar > commons-logging-1.1.3.jar libthrift-0.9.0.jar > hive-common-0.13.0.2.1.2.0-402.jar hive-service-0.13.0.2.1.2.0-402.jar > hive-jdbc-0.13.0.2.1.2.0-402.jar hadoop-common-2.4.0.2.1.2.0-402.jar > slf4j-api-1.7.5.jar guava-11.0.2.jar
Comments
Post a Comment