I have an tomcat 6 with an configured JNDI Tomcat JDBC Data Sources Resource Factory. Now my task is to verify that the connection pool has a minimal max size.
(If it is less, I need to disable some function or print at least a warning.)
But I don’t know how to get access to that value.
The Application (Spring) access the DataSource via JNDI, but this is only the data source (org.apache.tomcat.dbcp.dbcp.BasicDataSource) but I need the Factory (org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory) because the Factory only knows the value.
So how to read the org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory.maxActive property within an application?
Not the right thing to do – but if you insist you can cast the DataSource to org.apache.tomcat.dbcp.dbcp.BasicDataSource and then call the getMaxActive method on it. The value in the property file will be set onto the factory which then initializes the corresponding properties in the DataSource. The datasource object returned might not be an instance of BasicDataSource – it might get wrapped.