content top

Hadoop Architecture Explained !!!

Read More

Connecting Hive Server with JAVA

Use the following command to start the Hive server.

$HIVE_HOME/bin/hive –service hiveserver

Once the server is up, create a regualar java project in eclipse.

Add the following libraries to your project.

1. hadoop-core-1.1.2.jar which you can find in $HADOOP_HOME directory

2. all the jars files which are residing in $HIVE_HOME/lib

You can use two type of drivers to connect with HIVE.

1. JDBC Driver
connetion string : jdbc:odbc://localhost:10000/default
Driver class : sun.jdbc.odbc.JdbcOdbcDriver

2. HIVE Driver

connetion string : jdbc:hive://localhost:10000/default
Driver class : org.apache.hadoop.hive.jdbc.HiveDriver

* In place of localhost you can use ipaddress

Here is the sample program which connect with hive and display the tables in it.

import java.sql.SQLException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.DriverManager;

public class HiveClient {
	 private static String driverName = "org.apache.hadoop.hive.jdbc.HiveDriver";
     public static void main(String[] args) throws SQLException {
	    try {
	    } catch (ClassNotFoundException e) {
	    Connection con = DriverManager.getConnection("jdbc:hive://localhost:10000/default", "", "");
	    Statement stmt = con.createStatement();

	    ResultSet res;
	    String sql;
	    sql = "show tables";
	    System.out.println("Running: " + sql);
	    res = stmt.executeQuery(sql);
	    while ( {


If you have downloaded hive stable releaseĀ  (which is currently release on 18-Dec-2012) make sure you have closed all hive connections except hive server.

Make sure your metastore_db folder have correct user access permissions.


Read More



Read More
content top
%d bloggers like this:
shared on