开发者

c3p0 getConnection does not return or throw Exception once acquireRetryAttempts reached

Using c3p0 for my connection pool, the thread calling c3p0 appears to be terminated or left in an undefined state after the connection pool exhausts its retry attempts.

The connection pool is defined as such:

    private val pool = new ComboPooledDataSource
    pool.setDriverClass(config("database.driverClass").as[String])
    pool.setJdbcUrl(config("database.jdbcUrl").as[String])
    pool.setUser(config("database.user").as[String])
    pool.setPassword(config("database.password").as[String])
    pool.setAcquireRetryAttempts(5)

The client code calls getConnection, which blocks briefly while c3p0 spins through the connection retry attempts. The strange thing is that it doesn't really seem to return back from this call. From the documentation, I expected an Exception to be thrown:

If all attempts fail, any clients waiting for Connections from the 
DataSource will see an Exception, indicating that a Connection 
could not be acquired

It's very bizarre. It definitely does not return, and it does not throw an Exception.The client code that is calling getConnection from a Executors.newSingleThreadScheduledExecutor that runs every 5 seconds. When the call to getConnection seems to evaporate, the scheduled executor thread also seems to stop executing at all.

In this case I'm intentionally leaving the database off so that I can figure out what's going on here. Any ideas?

UPDATE: Strangely enough, if I don't use a sc开发者_运维百科heduled executor and instead run it in my own monitor thread, #getConnection performs as expected.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜