mysql - Unable to get the hive remote metastore table information over thrift -


i can metastore table information on local mysql metastore setup hive using below program.

import java.sql.connection; import java.sql.drivermanager; import java.sql.resultset; import java.sql.statement;  import org.apache.hadoop.fs.path; import org.apache.hadoop.hive.conf.hiveconf; import org.apache.hadoop.hive.conf.hiveconf.confvars;  public class metastoretest {      public static void main(string[] args) throws exception {          connection conn = null;         try {             hiveconf conf = new hiveconf();             conf.addresource(new path("/home/hadoop/hive-0.12.0/conf/hive-site.xml"));             class.forname(conf.getvar(confvars.metastore_connection_driver));             conn = drivermanager.getconnection(                     conf.getvar(confvars.metastoreconnecturlkey),                     conf.getvar(confvars.metastore_connection_user_name),                     conf.getvar(confvars.metastorepwd));              statement st = conn.createstatement();             resultset rs = st.executequery(                 "select t.tbl_name, s.location tbls t " +                 "join sds s on t.sd_id = s.sd_id");             while (rs.next()) {                 system.out.println(rs.getstring(1) + " : " + rs.getstring(2));             }         }         {             if (conn != null) {                 conn.close();             }         }      } } 

currently trying above program metastore tables remote metastore using thrift.in current hive-site.xml have these params,

hive.metastore.uris = thrift://host1:9083, thrift://host2:9083 hive.metastore.local = false 

there no params :

javax.jdo.option.connectiondrivername, javax.jdo.option.connectionusername, javax.jdo.option.connectionpassword 

so, how can fetch metatable information on thrift protocol. running above code on host2. please suggest.

also when run above code, shows information on :

metastore_connection_driver derby connection embedded driver,  metastoreconnecturlkey jdbc:mysql://<host name>/<database name>?createdatabaseifnotexist=true,  metastore_connection_user_name "app" ,  metastorepwd "mine" 

replace section of code :

conf.addresource(new path("/home/hadoop/hive-0.12.0/conf/hive-site.xml")); class.forname(conf.getvar(confvars.metastore_connection_driver)); conn = drivermanager.getconnection(        conf.getvar(confvars.metastoreconnecturlkey),        conf.getvar(confvars.metastore_connection_user_name),        conf.getvar(confvars.metastorepwd)); 

with below :

class.forname("com.mysql.jdbc.driver"); conn = drivermanager.getconnection("jdbc:mysql://host2:3306/metastore", "urusername", "urpassword"); 

[note :change metastore dbname, user , password accordingly per setup.]

now :

statement st = conn.createstatement(); resultset rs = st.executequery("show tables"); while (rs.next()) {    system.out.println("tables:" +rs.getstring(1)); } 

see getting metastore table names or not.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -