Impala Database Connection using Hikari Pool in Springboot

Need to add ImpalaJDBC41.jar in your project, then you have to add the configuration file as below

@Value("${impala.maxPoolSize}")
private String connectionPoolSize;
@Value("${impala.minimumIdleTime}")
private String minimumIdleTime;
@Value("${impala.connectionTimeOut}")
private String connectionTimeOut;
@Value("${impala.idleTimeOut}")
private String idleTimeOut;
@Value("${impala.spring.fqdn}")
private String krb_kdc;
@Value("${impala.domain}")
private String impalaDomain;
@Bean
	public HikariDataSource impalaDS() throws SQLException, PropertyVetoException {
		// System.setProperty("sun.security.krb5.debug", "true");
		// System.setProperty("sun.security.jgss.debug", "true");
		System.setProperty("java.security.krb5.realm", impalaDomain);
		System.setProperty("java.security.krb5.kdc", krb_kdc);
		
System.setProperty("javax.security.auth.useSubjectCredsOnly", "false");
		System.setProperty("java.security.krb5.conf", krbFile);
		System.setProperty("java.security.auth.login.config", jassFile);
		System.setProperty("sun.security.provider.certpath", trustStore);
		Configuration conf = new Configuration();
		conf.set("hadoop.security.authentication", "kerberos");
		UserGroupInformation.setConfiguration(conf);
		DataSource impalaDS = new DataSource();
		impalaDS.setURL(jdbcURL);
		HikariDataSource hikariDS = new HikariDataSource();
		hikariDS.setDataSource(impalaDS);
		hikariDS.setMaximumPoolSize(Integer.valueOf(connectionPoolSize));
		hikariDS.setMinimumIdle(Integer.valueOf(minimumIdleTime));
		hikariDS.setAutoCommit(true);
		hikariDS.setConnectionTimeout(Integer.valueOf(connectionTimeOut));
		hikariDS.setIdleTimeout(Integer.valueOf(idleTimeOut));
		return hikariDS;
	}

Impala JDBC Jar can be downloaded from Link-https://cloudera.com/downloads/connectors/impala/jdbc/2-6-4.html

Documentation available at- https://docs.cloudera.com/documentation/enterprise/5-9-x/topics/impala_jdbc.html

Full Class with code details can be found here in GitHub link-https://github.com/devrishal/Temp/blob/master/ImpalaDataSourceConfig.java


Posted

in

by

Comments

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.