当前位置:网站首页>oracle连接池长时间不使用连接失效问题
oracle连接池长时间不使用连接失效问题
2022-07-06 19:26:00 【傲娇的喵酱】
背景:
我用python Oracle.SessionPool() 封装了连接池。启动项目后,一段时间内可以使用,
过几个小时不使用,再触发,连接池的连接就失效了。
原因:
我碰到的实际例子如下:
Web服务器与数据库之间有一个安全防火墙,这个防火墙会定期检查连接,如果某个连接长时间(30分钟)没有数据流过,就会被关闭。这种关闭使得检测连接还是打开的,却不能执行sql语句。但是如果连接一直有数据流动,就不会被关闭。
设置定期检测后,比较好解决了这个问题。
Oracle的实现上有这样一个设置,即给一个测试语句来测试数据库连接。一般都用 select 1 from dual 。 另外还有一个设置就是多长时间检测一次。一般设置15分钟。
也就是说Oracle的实现的方法,会自动定期用这个语句去检测数据库的连接,一旦检测到连接失败,就关闭连接并重新建立连接。
因此我建议楼主可以考虑这样的机制。毕竟网络连接是完全有可能断开的。
具体的解决方案,还是要自己探索的,我也没搞定。
原文地址:
边栏推荐
- Redis introduction complete tutorial: replication principle
- 代码调试core-踩内存
- 哈希表及完整注释
- 【Socket】①Socket技术概述
- 2022 spring recruitment begins, and a collection of 10000 word interview questions will help you
- Detailed explanation of 19 dimensional integrated navigation module sinsgps in psins (time synchronization part)
- 服装企业部署MES管理系统的五个原因
- Derivative, partial derivative, directional derivative
- 测试优惠券要怎么写测试用例?
- Redis入门完整教程:问题定位与优化
猜你喜欢

Qt蓝牙:QBluetoothDeviceInfo

Matlb| economic scheduling with energy storage, opportunity constraints and robust optimization

What are the applications and benefits of MES management system
Django database (SQLite) basic introductory tutorial

The panel floating with the mouse in unity can adapt to the size of text content

Number theory --- fast power, fast power inverse element

软件测试——Jmeter接口测试之常用断言

Five reasons for clothing enterprises to deploy MES management system

Niuke programming problem -- double pointer of 101 must be brushed

Left value, right value
随机推荐
Redis入门完整教程:客户端管理
【Socket】①Socket技术概述
Utilisation de la promesse dans es6
6-6 vulnerability exploitation SSH security defense
Matlb| economic scheduling with energy storage, opportunity constraints and robust optimization
Detailed explanation of 19 dimensional integrated navigation module sinsgps in psins (time synchronization part)
Niuke programming problem -- double pointer of 101 must be brushed
Classify the features of pictures with full connection +softmax
[secretly kill little partner pytorch20 days] - [Day1] - [example of structured data modeling process]
MySQL
巴比特 | 元宇宙每日必读:IP授权是NFT的破圈之路吗?它的难点在哪里?Holder该如何选择合作平台?...
导数、偏导数、方向导数
代码调试core-踩内存
Unity uses maskablegraphic to draw a line with an arrow
密码学系列之:在线证书状态协议OCSP详解
Redis Getting started tutoriel complet: positionnement et optimisation des problèmes
哈希表及完整注释
widerperson数据集转化为YOLO格式
牛客编程题--必刷101之双指针篇
普通测试年薪15w,测试开发年薪30w+,二者差距在哪?