I have a problem with the Oracle Universal Connection Pool (UCP) implemented in a Scala application, for an Oracle Database.
It works perfectly while there's a connection to the database, but when the network has some problem for a limited period of time (the application or the database goes offline) it obviously fails to create a Connection while the problem persists, but then it doesn't manage to create new ones when the application can ping the database again. The only way to get the application work again is to restart it.
I've set up a class in which I manage the connection, and I create the pool data source with this method:
private def createConnectionPool(
connectionString: String,
username: String,
password: String
): PoolDataSource =
{
val p = PoolDataSourceFactory.getPoolDataSource()
p.setConnectionPoolName("main_ucp_pool")
p.setConnectionFactoryClassName("oracle.jdbc.pool.OracleDataSource")
p.setURL(connectionString)
p.setUser(username)
p.setPassword(password)
p.setInitialPoolSize(5)
p.setMinPoolSize(3)
p.setMaxPoolSize(20)
p
}
private lazy val pds = createConnectionPool('url', 'username', 'pass')
Then, every time I need a database connection, I get it through this method invocation:
pds.getConnection()
Am I missing something in the code, or is it true that the pool data source should retry to establish a connection to the database when the getConnection
method is invoked, even after a network problem?
In other words, if it fails to create the connection when the network goes down, the second time, if the application can now ping the database, the connection must be established?