Reputation: 33
I'm developing Spring boot-based application with auto-configured Tomcat pooling DataSource. I have to call the same Oracle stored procedure under different DB schemas (there are execution grants for all of them), and I don't have specified list of user/password in advance. But I know credentials at the moment of procedure call. I use getConnection(user, password) method of dataSource object to receive connection and it works fine. But if I'll call procedure three times one by one - for user A, user B and again user A, connection method reconnect() will be called twice (for user B and for second call with user A) - because ConnectionPool object, used in DataSource, pops the same connection from idle queue, checks its user and password and connects to DB again with new credentials. As result, I loss all benefits of connection pool.
Could you tell me, please, does some implementation of connection pool, which caches idle connection by username? Or maybe some another way to decrease re-connection time? Unfortunately, I can't change Oracle procedure or even implement wrapper for it.
Upvotes: 1
Views: 396
Reputation: 33
C3P0 ComboPooledDataSource is pretty good solution. It stores connection pools in Map with user|password key
Upvotes: 2