本帖最后由 willgone 于 2017-06-21 10:56 编辑
平台配置在附件中。
private static String driverName1 = "org.apache.hive.jdbc.HiveDriver";
Class.forName(driverName1);
String url="jdbc:hive2://192.168.160.241:21076/default";
Connection con = DriverManager.getConnection(url, "", "");
Statement stmt = con.createStatement();
String createtable= "CREATE EXTERNAL TABLE if not exists netposa(id int,name string) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' ";
System.out.println("Running: " + sql);
stmt.execute(createtable);
报错信息如下:
Exception in thread "main" java.sql.SQLException: Could not open client transport with JDBC Uri: jdbc:hive2://192.168.160.241:21076/default: java.net.ConnectException: Connection refused: connect
at org.apache.hive.jdbc.HiveConnection.openTransport(HiveConnection.java:231)
at org.apache.hive.jdbc.HiveConnection.(HiveConnection.java:176)
at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:105)
at java.sql.DriverManager.getConnection(DriverManager.java:579)
at java.sql.DriverManager.getConnection(DriverManager.java:221)
at com.netposa.di.utils.HiveUtils.main(HiveUtils.java:14)
Caused by: org.apache.thrift.transport.TTransportException: java.net.ConnectException: Connection refused: connect
at org.apache.thrift.transport.TSocket.open(TSocket.java:187)
at org.apache.thrift.transport.TSaslTransport.open(TSaslTransport.java:266)
at org.apache.thrift.transport.TSaslClientTransport.open(TSaslClientTransport.java:37)
at org.apache.hive.jdbc.HiveConnection.openTransport(HiveConnection.java:204)
... 5 more