0

I have a java app (jdk 11) that uses HikariCP (version 4.0.3) to execute queries and return results. I am using sqlServer java lib version 8.2.0.jre11 & the app runs on a Kubernetes cluster.

Lately I have been seeing two different errors:

  1. Happens when calling createPool() below. "Error thrown while acquiring connection from data source ? Caused by: java.net.SocketTimeoutException: Read Time out"

  2. Happens when calling getConnection() "Caused by: FAILED to get database connection driver."

Both these are happening sporadically. Any ideas/hints/tips as to what's going on would be appreciated. I turned on the debug level logging and it doesn't show any connection leaks when it does manage to make connections.

Thanks

public class DBTester{

private final HikariPool  pool;

DBTester( ){
this.pool = createPool( createConfig() );
}

protected final HikariPool createPool( HikariConfig  pool ){
   return new HikariPool(config);
}

public final Connection getConnection(){
   return pool.getConnection();
}

private static final HikariConfig createConfig( ){

HikariConfig config = new HikariConfig();
config.setPoolName("TestPool");
config.setDriverClassName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
config.setJdbcUrl("jdbc:sqlserver://DBNAME.company.com:4444;databaseName=testDB;integratedSecurity=true;authenticationSchema=JavaKerberos");
config.setMinimumIdle( 10 );
config.setMaximumPoolSize( 20 );
config.setAutoCommit( false );
config.setReadOnly( false );
config.setIdleTimeout( 60_0000 );
config.setConnectionTimeout(60_000);
config.setLeakDetectionThreshold( 60_000 );
config.setConnectionInitSql("SELECT 1");
config.setConnectionTestQuery("SELECT 1");
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("useServerPrepStmts", "true");
config.addDataSourceProperty("cacheResultsSetMeta", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
}

}
CaptainHastings
  • 1,557
  • 1
  • 15
  • 32
  • Seems like connections returned to the pool may be idle timing out. Haven't tried with Hikari, but does it support the JDBC data source property, testOnBorrow? – AlwaysLearning Jul 27 '21 at 01:16
  • See if answer helps https://stackoverflow.com/questions/25354626/implementing-hikaricp-with-microsoft-sql-server – Ori Marko Jul 27 '21 at 11:28

0 Answers0