jQuery in Action, 3rd edition
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
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:

java.io.IOException: Cannot initialize Cluster. Please check your configuration for mapreduce.framework.name and the correspond server addresses. at org.apache.hadoop.mapreduce.Cl uster.initialize(Cluster.java: 121) at org.apache.hadoop.mapreduce.Cl uster.(Cluster.java:83) at org.apache.hadoop.mapreduce.Cl uster.(Cluster.java:76) at org.apache.hadoop.mapred.JobCl ient.init(JobClient.java:478) at org.apache.hadoop.mapred.JobCl ient.(JobClient.java:457) 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(Task.java:13 8) at org.apache.hadoop.hive.ql.exec .TaskRunner.runSequential(Task Runner.java:57) at org.apache.hadoop.hive.ql.Driv er.launchTask(Driver.java:1374 ) at org.apache.hadoop.hive.ql.Driv er.execute(Driver.java:1160) at org.apache.hadoop.hive.ql.Driv er.run(Driver.java:973) at org.apache.hadoop.hive.ql.Driv er.run(Driver.java:893) at org.apache.hadoop.hive.service .HiveServer$HiveServerHandler. execute(HiveServer.java:198) at org.apache.hadoop.hive.service .ThriftHive$Processor$execute. getResult(ThriftHive.java:644) at org.apache.hadoop.hive.service .ThriftHive$Processor$execute. getResult(ThriftHive.java:628) at org.apache.thrift.ProcessFunct ion.process(ProcessFunction.ja va:39) at org.apache.thrift.TBaseProcess or.process(TBaseProcessor.java :39) at org.apache.thrift.server.TThre adPoolServer$WorkerProcess.run (TThreadPoolServer.java:206) at java.util.concurrent.ThreadPoo lExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoo lExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Job Submission failed with exception 'java.io.IOException(Cannot initialize Cluster. Please check your configuration for mapreduce.framework.name 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: http://aspose.com/file-tools
subject: Hadoop-Hive JDBC client throws SQLException
jQuery in Action, 3rd edition