Tomcat连接池与准备好的语句缓存 [英] Tomcat connection pooling with prepared statement cache
问题描述
从DBCP连接池升级到Tomcat自己的实现(基于优秀的比较此处);我有点困惑为什么他们放弃这两个属性,同时保留其他所有属性:
Having upgraded from DBCP connection pooling to Tomcat's own implementation (based on the excellent comparison here); I'm a little confused as to why they've dropped these 2 properties, while keeping everything else:
poolPreparedStatements="true"
maxOpenPreparedStatements="10000"
这是否意味着不支持预准备的语句池这个实现?并且默认情况下每个连接是否都维护自己的预准备语句池?
Does this mean that prepared statement pooling is not supported in this implementation? And does each connection maintain its own pool of prepared statements by default?
我花了相当长的时间研究这个并且没有找到明确的答案!
I've spent a considerable time researching this and have found no clear answer!
感谢您的时间。
推荐答案
Tomcat(相当)新的jdbc-pool确实有一个语句缓存也是。
您可以使用 JDBC拦截器
启用和配置它,在池创建期间将其设置为 JDBC属性 。
请查看文档以获取更多信息以及存在哪些配置可能性。
Tomcat's (fairly) new jdbc-pool does have a statement cache, too.
You can enable and configure it using a JDBC interceptor
, which is set as a JDBC property during pool creation.
Please have a look at the documentation for more information and which configuration possibilities exist.
基本上这样做:
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);
这篇关于Tomcat连接池与准备好的语句缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!