java - Connecting to remote HIVE server -
i trying connect remote hive server. have following maven java code :
private static string drivername = "org.apache.hadoop.hive.jdbc.hivedriver"; public static void main(string[] args) throws sqlexception { try { // register driver , create driver instance class.forname(drivername); } catch (classnotfoundexception ex) { logger.getlogger(forhive.class.getname()).log(level.severe, null, ex); } // connection system.out.println("before trying connect"); connection con = drivermanager.getconnection("jdbc:hive://<hostip>:10000/", "hive", ""); system.out.println("connected"); // create statement statement stmt = con.createstatement(); // execute statement stmt.executequery("create table if not exists " +" consultant ( eid int, name string, " +" salary string, destignation string)" +" comment ‘employee details’" +" row format delimited" +" fields terminated ‘\t’" +" lines terminated ‘\n’" +" stored textfile;"); system.out.println("table employee created."); con.close();
}
but when execute gets stuck while trying connect server , throws no exception either.
try use org.apache.hive.jdbc.hivedriver
driver. connection string jdbc:hive2://<host>:10000/
Comments
Post a Comment