Support Questions

Find answers, ask questions, and share your expertise

Problem in getting impala connection using JDBC

avatar
New Contributor

I am trying to connect to imapala using jdbc and I am getting the following exception

 

 

java.sql.SQLException: [Simba][ImpalaJDBCDriver](500151) Error setting/closing session: {0}.

at com.cloudera.hivecommon.api.HS2Client.openSession(Unknown Source)

at com.cloudera.hivecommon.api.HS2Client.<init>(Unknown Source)

at com.cloudera.hivecommon.api.HiveServer2ClientFactory.createClient(Unknown Source)

at com.cloudera.hivecommon.core.HiveJDBCCommonConnection.connect(Unknown Source)

at com.cloudera.impala.core.ImpalaJDBCConnection.connect(Unknown Source)

at com.cloudera.jdbc.common.BaseConnectionFactory.doConnect(Unknown Source)

at com.cloudera.jdbc.common.AbstractDriver.connect(Unknown Source)

at java.sql.DriverManager.getConnection(DriverManager.java:664)

at java.sql.DriverManager.getConnection(DriverManager.java:270)

Caused by: com.cloudera.support.exceptions.GeneralException: [Simba][ImpalaJDBCDriver](500151) Error setting/closing session: {0}.

... 9 more

Caused by: org.apache.thrift.transport.TTransportException

at org.apache.thrift.transport.TIOStreamTransport.read(TIOStreamTransport.java:132)

at org.apache.thrift.transport.TTransport.readAll(TTransport.java:84)

at org.apache.thrift.protocol.TBinaryProtocol.readAll(TBinaryProtocol.java:378)

at org.apache.thrift.protocol.TBinaryProtocol.readI32(TBinaryProtocol.java:297)

at org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtocol.java:204)

at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:69)

at org.apache.hive.service.cli.thrift.TCLIService$Client.recv_OpenSession(TCLIService.java:159)

at com.cloudera.hivecommon.api.HS2ClientWrapper.recv_OpenSession(Unknown Source)

at org.apache.hive.service.cli.thrift.TCLIService$Client.OpenSession(TCLIService.java:146)

at com.cloudera.hivecommon.api.HS2ClientWrapper.OpenSession(Unknown Source)

at com.cloudera.hivecommon.api.HS2Client.openSession(Unknown Source)

at com.cloudera.hivecommon.api.HS2Client.<init>(Unknown Source)

at com.cloudera.hivecommon.api.HiveServer2ClientFactory.createClient(Unknown Source)

at com.cloudera.hivecommon.core.HiveJDBCCommonConnection.connect(Unknown Source)

at com.cloudera.impala.core.ImpalaJDBCConnection.connect(Unknown Source)

at com.cloudera.jdbc.common.BaseConnectionFactory.doConnect(Unknown Source)

at com.cloudera.jdbc.common.AbstractDriver.connect(Unknown Source)

at java.sql.DriverManager.getConnection(DriverManager.java:664)

at java.sql.DriverManager.getConnection(DriverManager.java:270)

at com.priceline.cache22dataconsole.test.TestImpalaConnection.main(TestImpalaConnection.java:56)

 

Anyone has any Idea why I am getting this exception.This is the code example : 

Authentication is successful.

Class.forName("com.cloudera.impala.jdbc41.Driver");

connection = DriverManager.getConnection(CONNECTION_URL);

 

2 REPLIES 2

avatar
Champion

Stack trace tells us that there is a connection establishment issue 

Impala accept connection via this port  21050 . Could you please make sure if this open and make sure you are using 21050 port in your code.

 

https://www.cloudera.com/documentation/enterprise/5-9-x/topics/impala_ports.html#ports

 

 

Are you using shared hive metastore  for impala . If so 

please check the status of the below following on the host you are trying to connect  . 

 

 

sudo service hive-metastore status
sudo service hive-server2 status
sudo service impala-state-store status

sudo service impala-catalog status

 

avatar
New Contributor

I am able to connect finally. 

 

I had to authenticate using kerberos so initially I was authenticating like this :

 

Sample () {

Configuration conf = new Configuration();

conf.set("hadoop.security.authentication", "Kerberos");

UserGroupInformation.setConfiguration(conf);

UserGroupInformation.loginUserFromKeytab(user, keytabPath);

ugi = UserGroupInformation.getLoginUser();

}

after this URL of this type : 

jdbc:impala://myhost.example.com:21050/;principal=impala/myhost.example.com@H2.EXAMPLE.COM;SSL=1;sslTrustStore=trustStorePath;trsutStorePassword=xyz;

Creating datasource and get connection.

This did not work and was giving above mentioned exception.

 

Later Modification :

Using AuthMech = 1 in URL and setting

KrbHostFQDN, 

KrbServiceName, 

KrbAuthType in URL.

 

Not executing Sample() after this and just setting these properties : 

 

java.security.krb5.conf = Your krb5.conf path

java.security.auth.login.config = login.ini

where login.ini is like this 

 

Client { com.sun.security.auth.module.Krb5LoginModule required useKeyTab=true keyTab="PathToTheKeyTab" principal="cloudera@CLOUDERA" doNotPrompt=true; };

 

Hopefully this may help to debug other guys struggling like me 🙂