package com.msr.DBConnections;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
public class HiveConn {
public static void main(String[] args) {
try{
Class.forName("org.apache.hive.jdbc.HiveDriver");
Connection con = DriverManager.getConnection("jdbc:hive2://10.25.3.209:10000/default","root","hadoop");
System.out.println(" CONNECTION >> "+con);
Statement st = con.createStatement();
String qry ="Create database BOTTLE";
st.executeQuery(qry);
}
catch(Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
System.out.println("exception raised in create database");
}
}
}
引发以下异常
线程中的异常" main" java.lang.NoSuchFieldError:位于org.apache的org.apache.hive.jdbc.HiveConnection.isHttpTransportMode(HiveConnection.java:304)的org.apache上的org.apache.hive.jdbc.HiveConnection.openTransport(HiveConnection.java:181)中的HIVE_SERVER2_TRANSPORT_MODE。 hive.jdbc.HiveConnection。(HiveConnection.java:164)位于java.sql.DriverManager的java.sql.DriverManager.getConnection(未知来源)的org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:105) com.msr.DBConnections.HiveConn.main上的.getConnection(未知来源)(HiveConn.java:19)