Dear all,
I have encountered a serious problem while fetching Hive metadata through Eclipse. I am able to connect Hive through JDBC program in Eclipse and also able to fetch data from it.
But when I try to connect to Hive  metadata  I got the following error :-

Driver Loaded.
Hive history file=/tmp/root/hive_job_log_root_201009201158_301097049.txt
Sep 20, 2010 11:58:13 AM org.apache.hadoop.hive.ql.session.SessionState$LogHelper printInfo INFO: Hive history file=/tmp/root/hive_job_log_root_201009201158_301097049.txt
Got Connection.
Exception in thread "main" java.sql.SQLException: Method not supported
at org.apache.hadoop.hive.jdbc.HiveDatabaseMetaData.getTables(HiveDatabaseMetaData.java:710)
   at test.Jdbchivemetadata.main(Jdbchivemetadata.java:15)
I use
Hadoop = 0.20.2
Hive = 0.5 with Mysql As metastore

***My work for this error***
I think hive_jdbc.jar doesn't support these features to access metastore.
I see HiveDatabaseMetaData.java and it has all methods with exceptions 'Method Not Supported ';

Can anybody please tell me how to use Hive Metadata if it is possible.
The codes are attached with mail.

Thanks and Regards
Adarsh Sharma



package test;

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


public class Jdbcclient {
  private static String driverName = "org.apache.hadoop.hive.jdbc.HiveDriver";

  /**
   * @param args
   * @throws SQLException
   */
  public static void main(String[] args) throws SQLException {
      try {
    	  System.out.println("Hive Execution");
      Class.forName("org.apache.hadoop.hive.jdbc.HiveDriver");
      
    } catch (ClassNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      //System.exit(1);
    }
    Connection con = DriverManager.getConnection("jdbc:hive://192.168.0.25:10000/default", "","");
    
    //Connection con = DriverManager.getConnection("jdbc:derby://ws-test:1527/metastore_db", "","");
    Statement stmt = con.createStatement();
   System.out.println("con "+con);
  // String tableName = "master_seed";
   String tableName = "student";
    
   
    // describe table
    String sql = "describe " + tableName;
   System.out.println("Running: " + sql);
   ResultSet res = stmt.executeQuery(sql);
   while (res.next()) {
     System.out.println(res.getString(1) + "\t" + res.getString(2));
   }
  
   
    sql = "select name from " + tableName;
    System.out.println("Running: " + sql);
    res = stmt.executeQuery(sql);
    while (res.next()) {
      System.out.println(res.getString(1));
    }
}
}
package test;

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


public class Jdbchivemetadata {
  
  public static void main(String[] args) throws Exception {
    DatabaseMetaData md = conn.getMetaData();
    ResultSet rs = md.getTables(null, null, "%", null);
    while (rs.next()) {
      System.out.println(rs.getString(3));
    }  }
   static Connection conn;

  static Statement st;

  static {
    try {
      // Step 1: Load the JDBC driver.
      Class.forName("org.apache.hadoop.hive.jdbc.HiveDriver");
      System.out.println("Driver Loaded.");
      // Step 2: Establish the connection to the database.
      String url = "jdbc:hive://192.168.0.25:10000/default";

      conn = DriverManager.getConnection(url, "student", "");
      System.out.println("Got Connection.");

      st = conn.createStatement();
    } catch (Exception e) {
      System.err.println("Got an exception! ");
      e.printStackTrace();
      System.exit(0);
    }
  }
}
   
  
  


    
    
  

Reply via email to