c# - 当连接状态关闭时,Ora-24309 怎么会发生?
问题描述
//I got a Connection which is kept alive..
IDbConnection con = CreatyMyOracleConnection();
//Later, if I want to use the connection i check if it's closed to (re-)open it.'
if (con.State == ConnectionState.Closed)
con.Open() // Here OracleException 24309 is thrown
有时我得到一个:
ORA-24309“已经连接到服务器”。
如果在打开之前检查状态怎么会这样?
尝试/捕获似乎是一个丑陋的解决方案。我认为应该有一种方法来识别如何处理连接。在(重新)打开它之前我应该如何检查连接?
我目前正在使用非托管 ODP.Net 11.2。
解决方案
ConnectionState
可
- 破碎的
- 关闭
- 连接
- 执行
- 抓取
- 打开
所以,你可以更好地使用
if (con.State != ConnectionState.Open)
con.Open();
推荐阅读
- spring - Quarkus 框架是从 Spring 框架的核心创建的?
- python-3.x - *args 在 list() 函数的情况下如何工作?
- html - 当我在其他 div 中有 div 时,我不能让它们粘在顶部或底部
- node.js - IntelliJ:使用 jest 和 Vue.js2 在断点处停止执行单个文件组件
- javascript - 使用 JavaScript 以编程方式调度键盘(例如按键)事件
- amazon-ecs - 在具有 Aurora 无服务器 (PGSQL) 的 ECS Fargate 上使用 rubyagent 在 NewRelic 上进行数据库监控不起作用
- html5-video - 有没有办法使用 HTML5 视频标签在全屏模式下平滑地从一个视频源淡化到另一个视频源?
- python - BeautifulSoup 没有提取所有页面
- java - @Path 有效,但 @RequestMapping 没有 Java Spring Boot
- delphi - 如何将 4 字节字符串转换为 unicode 表情符号?