import java.sql.*;
Connection con = DriverManager.getConnection("jdbc:impala://<host>:<port>/;AuthMech=3;KrbRealm=<realm>;KrbHostFQDN=<host_fqdn>;KrbServiceName=<service_name>;SSL=1;SSLTrustStore=<truststore_path>;SSLTrustStorePwd=<truststore_password>;");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("<hive_query>");
用hive驱动包 调用
// Load the Hive JDBC driver
Class.forName("org.apache.hive.jdbc.HiveDriver");
// Create a connection using the Hive JDBC driver
Connection connection = DriverManager.getConnection("jdbc:hive2://<impala_host>:<impala_port>/;auth=noSasl");
// Create a statement object
Statement statement = connection.createStatement();
// Execute the query
ResultSet resultSet = statement.executeQuery("<your_impala_query>");