首页 > 解决方案 > 当连接状态关闭时,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。

标签: c#oracleoracle11godp.net

解决方案


ConnectionState

  • 破碎的
  • 关闭
  • 连接
  • 执行
  • 抓取
  • 打开

请参阅ConnectionState 枚举

所以,你可以更好地使用

if (con.State != ConnectionState.Open)
    con.Open();

推荐阅读