0

I use the following properties file content:

driverClassName=org.apache.derby.jdbc.EmbeddedDriver
jdbcUrl=jdbc:derby:D:\\development\\databases\\test;create=true
connectionTimeout=3000

and

HikariConfig config = new HikariConfig(propertiesFilePath);
HikariDataSource ds = new HikariDataSource(config);

During

new HikariDataSource(config);

the following exception is thrown: Caused by:

java.sql.SQLTransientConnectionException: HikariPool-0 - Connection is  not available, request timed out after 3002ms.
kari.pool.HikariPool.getConnection(HikariPool.java:195)
at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:147)
at com.zaxxer.hikari.pool.HikariPool.initializeConnections(HikariPool.java:510)

What I can see is that the database directories are created.

What I am doing wrong?

derby version: 10.10.1.1

HikariCP version: 2.4.3

Update

Well the solution is pretty simple. The connection timeout was just to short. If the database does not exist, the creation of the db just needs some time. After increasing the connection timeout everything works fine.

coder
  • 1,415
  • 2
  • 12
  • 15
  • When is this exception thrown exactly? Please show the code you use. This can for example happen if you don't close connections in your code and you reach the maximum number of connections (default: 10). – Mark Rotteveel Feb 14 '16 at 11:39
  • Maybe it will work when you replace the backslash with a forward slash - [Derby Dev guide](http://db.apache.org/derby/docs/10.12/devguide/cdevdvlp40350.html): The path separator in the path name is a forward slash (/), even in Windows path names. – vanOekel Feb 14 '16 at 11:54
  • @vanOekel: replacing the backslashes by forward slashes does't help – coder Feb 14 '16 at 13:09
  • Get it running *without* HikariCP ... and when you find the connection URL that works, plug that into HikariCP. The example URL that the derby documentation gives is: ``jdbc:derby:c:/databases/salesdb`` – brettw Feb 15 '16 at 20:19

0 Answers0