HicariCP connection pool seems not to work properly with alpakka-slick


#1

I’m trying to use alpakka-slick to access db2 db.
I’ve copied the configuration template for db2 from here:
https://developer.lightbend.com/docs/alpakka/current/slick.html

test {
  profile = "slick.jdbc.DB2Profile$"
  db {
//    connectionPool = disabled
    dataSourceClass = "slick.jdbc.DriverDataSource"
    connectionTimeout = 10s
    properties = {
      driver = "com.ibm.db2.jcc.DB2Driver"
      url = "xxx"
      user = "yyy"
      password = "zzz"
    }
  }
}

The problem is that when I specify

connectionPool = disabled
the app is able to connect to the DB and do the required stuff.
When I comment this row out, trying to use HicariCP connection pool - I start getting the following error:

[ERROR] [09/18/2018 16:39:04.789] [tt-batch-akka.actor.default-dispatcher-4] [akka.stream.Log(akka://tt-batch/system/StreamSupervisor-0)] [user] Upstream failed.
java.sql.SQLTransientConnectionException: claim-db.db - Connection is not available, request timed out after 10000ms.
	at com.zaxxer.hikari.pool.HikariPool.createTimeoutException(HikariPool.java:548)
	at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:186)
	at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:145)
	at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:83)
	at slick.jdbc.hikaricp.HikariCPJdbcDataSource.createConnection(HikariCPJdbcDataSource.scala:14)
	at slick.jdbc.JdbcBackend$BaseSession.<init>(JdbcBackend.scala:438)
	at slick.jdbc.JdbcBackend$DatabaseDef.createSession(JdbcBackend.scala:46)
	at slick.jdbc.JdbcBackend$DatabaseDef.createSession(JdbcBackend.scala:37)
	at slick.basic.BasicBackend$DatabaseDef.acquireSession(BasicBackend.scala:216)
	at slick.basic.BasicBackend$DatabaseDef.acquireSession$(BasicBackend.scala:215)
	at slick.jdbc.JdbcBackend$DatabaseDef.acquireSession(JdbcBackend.scala:37)
	at slick.basic.BasicBackend$DatabaseDef$$anon$3.run(BasicBackend.scala:279)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

Am I missing something?

EDITED:
Looks like I have to specify the test query like this:

connectionTestQuery = “SELECT 1 FROM SYSIBM.SYSDUMMY1”

It solved the issue.
But the error message was not helpful at all


#2

Looks like I had to explicitly specify the test query like this:

connectionTestQuery = “SELECT 1 FROM SYSIBM.SYSDUMMY1”

It started working now. Though the error message was not helpful at all.