'Simba][ImpalaJDBCDriver](500151) Error setting/closing session in Imapala jdbc connection

I am trying to connect to impala using JDBC connection. Imapala driver jar used is impalaJDBC41. Error occured while creating connection object 'con' Error is -[Simba]ImpalaJDBCDriver Error setting/closing session in Imapala jdbc connection

Code is as below:

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/[email protected]");
         Statement stmt = con.createStatement();
         String tableName = "yogesh";
         stmt.executeQuery("drop table " + tableName);
    }

}


Solution 1:[1]

url should be: jdbc:impala://192.168.8.183:21050;AuthMech=1;KrbRealm=abc.ENTERPRISENET.ORG;KrbHostFQDN=your-host;KrbServiceName=impala

and kerberos need 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/[email protected]", loader.getResource("secret/184_hdfs.keytab").getPath());
        UserGroupInformation loginUser = UserGroupInformation.getLoginUser();
        loginUser.doAs(new PrivilegedAction<Void>() {
            @Override
            public Void run() {
                connectImpala();
                return null;
            }
        });
}

Solution 2:[2]

I had the same error (code 500151) with the Cloudera JDBC driver for Hive, and was able to solve it by adding ;SocketTimeout=0 to my connection string.

Be sure to read the documentation to make sure you're not forgetting some properties:

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 laiwb
Solution 2 Narvarth