Question: I create a class SecureImpalaDataSource that extends DriverManagerDataSource, and use `UserGroupInformation.doAs()` to get a Connection to impala with keytab file. But I get the error as follow: 

> 
> java.sql.SQLException: [Simba]ImpalaJDBCDriver Error
>  initialized or created transport for authentication:
>  [Simba]ImpalaJDBCDriver Unable to connect to server: null.
> 
> 
> 

But I am successful when I get the connection with kerberos ticket cache in a test demo. Anyone can help me?

Answer: 
The result is that the HOST and the FQDN in my URL are inconsistent.
One way to authentication your jdbc connection is using ugi.doAs. Here is the sample code:

```
// 1. login use keytab
System.setProperty("java.security.krb5.realm", "XXX.COM");
System.setProperty("java.security.krb5.kdc", "kdcXXX");
Configuration conf = new Configuration();
conf.set("hadoop.security.authentication", "Kerberos");
UserGroupInformation.setConfiguration(conf);
UserGroupInformation ugi = UserGroupInformation.loginUserFromKeytabAndReturnUGI("test", "test.keytab");

// 2. create impala jdbc connection
Class.forName(JDBCDriverName);
conn = (Connection) ugi.doAs(new PrivilegedExceptionAction<Object>() {
  public Object run() {
    Connection tcon = null;
    try {
      tcon = DriverManager.getConnection(connectionUrl);
    } catch (SQLException e) {
      e.printStackTrace();
    }
    return tcon;
  }
});

// 3. execute query using conn
......

```