It's not a secret anymore!
The moose likes Hadoop and the fly likes Hadoop-Hive JDBC client throws SQLException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Databases » Hadoop
Bookmark "Hadoop-Hive JDBC client throws SQLException" Watch "Hadoop-Hive JDBC client throws SQLException" New topic

Hadoop-Hive JDBC client throws SQLException

C Shridhar

Joined: Jul 11, 2013
Posts: 1

I am connecting to a hive installation using a JDBC client code. I have created a test table with two columns(column1, column2) both string type. When i try executing simple queries like "select* from test" i get result in java program but queries with where clauses and other complex queries throw the following exception.

"Query returned non-zero code: 1, cause: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec .MapRedTask"

I have tried changing permissions of hdfs directories where file is present,/tmp on local directory but this didn't work.

This is my connection code

Connection con = DriverManager.getConnection( "jdbc:hive://"+host+ ":"+port+"/default", "", "");

Statement stmt = con.createStatement();

Error is thrown at executeQuery() method

Checking the logs on server gives the following exception: Cannot initialize Cluster. Please check your configuration for and the correspond server addresses. at org.apache.hadoop.mapreduce.Cl uster.initialize( 121) at org.apache.hadoop.mapreduce.Cl uster.( at org.apache.hadoop.mapreduce.Cl uster.( at org.apache.hadoop.mapred.JobCl ient.init( at org.apache.hadoop.mapred.JobCl ient.( at org.apache.hadoop.hive.ql.exec .ExecDriver.execute(ExecDriver .java:426) at org.apache.hadoop.hive.ql.exec .MapRedTask.execute(MapRedTask .java:138) at org.apache.hadoop.hive.ql.exec .Task.executeTask( 8) at org.apache.hadoop.hive.ql.exec .TaskRunner.runSequential(Task at org.apache.hadoop.hive.ql.Driv er.launchTask( ) at org.apache.hadoop.hive.ql.Driv er.execute( at org.apache.hadoop.hive.ql.Driv at org.apache.hadoop.hive.ql.Driv at org.apache.hadoop.hive.service .HiveServer$HiveServerHandler. execute( at org.apache.hadoop.hive.service .ThriftHive$Processor$execute. getResult( at org.apache.hadoop.hive.service .ThriftHive$Processor$execute. getResult( at org.apache.thrift.ProcessFunct ion.process(ProcessFunction.ja va:39) at org.apache.thrift.TBaseProcess or.process( :39) at org.apache.thrift.server.TThre adPoolServer$ ( at java.util.concurrent.ThreadPoo lExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoo lExecutor$ Source) at Source) Job Submission failed with exception ' initialize Cluster. Please check your configuration for and the correspond server addresses.)'

The queries work when run on a command prompt but not in JDBC client. Since the queries are working in hive shell, i am assuming there is no issue in configuration but something wrong with java execution.

I am using cloudera CDH4 hadoop/hive distribution.

I am stuck on this. Any suggestions would be helpful.
Rajesh Nagaraju
Ranch Hand

Joined: Nov 27, 2003
Posts: 63
You need to start hive thrift server
I agree. Here's the link:
subject: Hadoop-Hive JDBC client throws SQLException
It's not a secret anymore!