惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
GbyAI
GbyAI
Stack Overflow Blog
Stack Overflow Blog
Recent Announcements
Recent Announcements
D
DataBreaches.Net
量子位
C
Cybersecurity and Infrastructure Security Agency CISA
G
Google Developers Blog
小众软件
小众软件
Application and Cybersecurity Blog
Application and Cybersecurity Blog
MyScale Blog
MyScale Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Cisco Talos Blog
Cisco Talos Blog
P
Proofpoint News Feed
V
Vulnerabilities – Threatpost
Security Latest
Security Latest
T
Tenable Blog
Vercel News
Vercel News
AWS News Blog
AWS News Blog
Forbes - Security
Forbes - Security
M
MIT News - Artificial intelligence
S
Security Affairs
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Hacker News - Newest:
Hacker News - Newest: "LLM"
美团技术团队
L
Lohrmann on Cybersecurity
博客园 - 司徒正美
Last Week in AI
Last Week in AI
罗磊的独立博客
Project Zero
Project Zero
Cyberwarzone
Cyberwarzone
S
Schneier on Security
S
Secure Thoughts
T
Threatpost
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Google DeepMind News
Google DeepMind News
B
Blog RSS Feed
Y
Y Combinator Blog
F
Full Disclosure
N
Netflix TechBlog - Medium
博客园 - 叶小钗
A
Arctic Wolf
腾讯CDC
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
The Exploit Database - CXSecurity.com
Jina AI
Jina AI
Apple Machine Learning Research
Apple Machine Learning Research
C
Check Point Blog
C
CERT Recently Published Vulnerability Notes
www.infosecurity-magazine.com
www.infosecurity-magazine.com

博客园 - 茁壮的小草

join查询中索引建议 连接池介绍 JDBC介绍 Hadoop完全分布式搭建 Apache Hadoop YARN 使用 kubebuilder 创建并部署 k8s-operator 单链表反转 单链表操作 如何在Kubernetes 里添加自定义的 API 对象(一) 搭建golang开发环境(1.14之后版本) 【源码】Redis命令处理过程 K8S配置存活、就绪和启动探测器 【源码】Redis exists命令bug分析 【源码】Redis Server启动过程 K8S中的Objects MAC 安装MySQL-python 公司里使用gitlab管理项目 vscode配置django开发环境最佳实战(mac) virtualenv最佳实战(windows)
tomcat连接池的“bug”
茁壮的小草 · 2022-09-23 · via 博客园 - 茁壮的小草

Tomcat 连接池是从 Tomcat 7 开始重新编写的高并发连接池,用以取代以前 Tomcat 中使用的 DBCP 1 连接池,它可以配置在 Tomcat 中使用,也可以单独使用。

【注意的地方】:

在web应用程序中配置了Tomcat JDBC池,并使用Tomcat8.0.38添加了maven依赖项。从该池获取连接并检查autoCommit属性的值,它为“true”,然后将该连接的autoCommit设置为“false”。然后提交了事务,用完关闭该连接。

现在另一个程序从池中获得另一个连接,并检查autoCommit属性的值,它是“false”。但我原以为是true,毕竟是新连接。

后来使用Apache Common DBCP2池库,它没有这种行为。每当我从公共DBCP2池获取连接时,它都会返回autoCommit设置为“true”的连接。

我已经测试并看到了tomcat jdbc池的这种行为。

Connection con1 = basicDataSourceWrite.getConnection();
con1.setAutoCommit(false);
System.out.println(con1.getAutoCommit()+ " con1  " );
con1.commit();
con1.close();

Connection con2 = basicDataSourceWrite.getConnection();
System.out.println(con2.getAutoCommit()+ " con2  " );

Output of above code is

false con1
false con2

这是Tomcat JDBC的一个已知错误(或者说是一个尚未修复的特性)。仅设置defaultAutoCommit的值是不够的,还需要启用拦截器,拦截器将实际执行这些设置。这将使defaultAutoCommit值影响连接。

参考:

     https://stackoverflow.com/questions/48921625/tomcat-jdbc-pool-has-some-different-behaviour-about-connection-reuse

     https://coderanch.com/t/583969/databases/Tomcat-connection-pool-auto-commit