java获取hive表结构_如何使用java在hive中创建表?

我想使用

Java在hive中创建一个表.使用以下方法执行此操作:

public class HiveCreateTable {

private static String driverName = "com.facebook.presto.jdbc.PrestoDriver";

public static void main(String[] args) throws SQLException {

// Register driver and create driver instance

try {

Class.forName(driverName);

}

catch (ClassNotFoundException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

System.out.println("haiiiiii");

Connection con = DriverManager.getConnection("jdbc:presto://192.168.1.119:8082/default", "hadoop", "password");

con.setCatalog("hive");

con.setSchema("log");

Statement stmt = con.createStatement();

ResultSet res = stmt.executeQuery("create table access_log2 (cip string, csusername string, cscomputername string)");

System.out.println("Table created.");

con.close();

}

}

错误:

Exception in thread “main” java.sql.SQLException: Query failed

(#20150731_101653_00008_hv68j): Unknown type for column ‘cip’

最佳答案 在上面的代码中,您使用的是Presto JDBC驱动程序,而不是Hive.我不确定你想要实现什么,但Presto支持以下数据类型,其中String不是一个:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值