Jul 5th, 2007, 05:55 PM
getConnection() and OracleDataSource
I am using the OracleDataSource for ConnectionPooling and setting a max
limit to the Pool size. I am also using the
TransactionAwareDataSourceProxy class, the AbstractRoutingDataSource
class and the DataSourceUtils.getConnection() method to get a Connection
from the DataSource.
When I attempt to get a Connection from an OracleDataSource which has
reached the max, the OracleDataSource returns a null for the Connection
(not an Exception) The code in DataSourceUtils.getConnection() does not
check for null and the Connection Proxy class is created with a null
target for the Connection. An Exception is not thrown until an attempt
is made to use the Connection here:
at $Proxy0.createStatement(Unknown Source)
I would prefer to get some Exception or indicator when the
getConnection() fails (for whatever reason). Since I am using the
AbstractRoutingDataSource(), I could then try to get a Connection from
another DataSouce which may have Connections available.
Is it correct to create a Proxy class around a null Connection? Is this a bug?