我正在尝试使用JDBC连接连接到impala。 使用的Imapala驱动器罐是impalaJDBC41。 创建连接对象'con'时出错 错误是 - [Simba] ImpalaJDBCDriver错误设置/关闭Imapala jdbc连接中的会话
代码如下:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class JDBC_Connection1 {
private static String driverName = "com.cloudera.impala.jdbc41.Driver";
public static void main(String[] args) throws SQLException {
try {
Class.forName(driverName);
}
catch (ClassNotFoundException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
System.exit(1);
}
Connection con = DriverManager.getConnection("jdbc:impala://host:25004/;principal=impala/host@abc.ENTERPRISENET.ORG");
Statement stmt = con.createStatement();
String tableName = "yogesh";
stmt.executeQuery("drop table " + tableName);
}
}
答案 0 :(得分:0)
网址应为: JDBC:帕拉://192.168.8.183:21050; AuthMech = 1; KrbRealm = abc.ENTERPRISENET.ORG; KrbHostFQDN =您的主机; KrbServiceName =帕拉
和kerberos需要hadoop kerberos env
System.setProperty("sun.security.krb5.debug", "false");
System.setProperty("java.security.krb5.conf",loader.getResource("secret/krb5.ini").getPath());
org.apache.hadoop.conf.Configuration conf = new org.apache.hadoop.conf.Configuration();
conf.set("hadoop.security.authentication", "Kerberos");
UserGroupInformation.setConfiguration(conf);
UserGroupInformation.loginUserFromKeytab("hdfs/admin@HADOOP.COM", loader.getResource("secret/184_hdfs.keytab").getPath());
UserGroupInformation loginUser = UserGroupInformation.getLoginUser();
loginUser.doAs(new PrivilegedAction<Void>() {
@Override
public Void run() {
connectImpala();
return null;
}
});
}
答案 1 :(得分:0)
我和Hive的Cloudera JDBC驱动程序有相同的错误(代码500151),并且能够通过将;SocketTimeout=0
添加到我的连接字符串来解决它。
请务必阅读文档,以确保您不会忘记某些属性: