Combining Tomcat connections with a ready-made statement cache

Upgrading from DBCP connection pool to Tomcat's own implementation (based on excellent comparison here ); I'm a little confused why they dropped these 2 properties while preserving everything else:

poolPreparedStatements="true" maxOpenPreparedStatements="10000" 

Does this mean that support is not supported in this implementation? And by default, each connection supports its own pool of prepared statements?

I spent a lot of time studying this and did not find a clear answer!

Thank you for your time.

+3
source share
1 answer

In Tomcat (rightly) the new jdbc-pool also has a statement cache. You can enable and configure it using the JDBC interceptor , which is set as a JDBC property during pool creation .
Please see the documentation for more information and configuration options.

This is mainly done as follows:

  PoolProperties p = new PoolProperties(); p.setUrl("jdbc:your-jdbc-url"); p.setDriverClassName("your.jdbc.driver.class"); p.setUsername("user"); p.setPassword("password"); p.setJdbcInterceptors( "org.apache.tomcat.jdbc.pool.interceptor.StatementCache"); DataSource datasource = new DataSource(); datasource.setPoolProperties(p); 
+6
source

All Articles