Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用java在配置单元中显示创建表_Java_Hadoop_Jdbc_Hive - Fatal编程技术网

使用java在配置单元中显示创建表

使用java在配置单元中显示创建表,java,hadoop,jdbc,hive,Java,Hadoop,Jdbc,Hive,我试图通过JDBC配置单元连接执行showcreatetable语句。目的是获取包含配置单元表数据的文件的位置 我尝试了以下代码,但出现以下异常: ResultSet rs = stmt.executeQuery(hiveTable); System.out.println("Resultset not null"+(rs != null)); int i = 0; while(rs.next()){ System.out.println(rs.getS

我试图通过JDBC配置单元连接执行showcreatetable语句。目的是获取包含配置单元表数据的文件的位置

我尝试了以下代码,但出现以下异常:

ResultSet rs = stmt.executeQuery(hiveTable);

    System.out.println("Resultset not null"+(rs != null));
    int i = 0;
    while(rs.next()){
        System.out.println(rs.getString(i));
        i++;
}
例外情况:

Exception in thread "main" java.sql.SQLException: Error while compiling statement: FAILED: ParseException line 1:4 cannot recognize input near 'show' '<EOF>' '<EOF>' in ddl statement
        at org.apache.hive.jdbc.Utils.verifySuccess(Utils.java:120)
        at org.apache.hive.jdbc.Utils.verifySuccessWithInfo(Utils.java:108)
        at org.apache.hive.jdbc.HiveStatement.execute(HiveStatement.java:233)
        at org.apache.hive.jdbc.HiveStatement.executeQuery(HiveStatement.java:376)
        at com.capitalone.def.impl.TestClass.main(TestClass.java:33)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.apache.hadoop.util.RunJar.main(RunJar.java:212)

请帮助我解决此问题。

使用以下代码可以获取表位置

HiveConf conf = new HiveConf();
conf.set(HiveConf.ConfVars.METASTOREURIS.varname, <metaStoreURI>);
HiveMetaStoreClient hiveMetaStoreClient = new HiveMetaStoreClient(conf);
Table tab = hiveMetaStoreClient.getTable(<db name>, <tab name>);
tab.getSd().getLocation()

hiveTable包含什么?显示创建表