加入收藏 | 设为首页 | 会员中心 | 我要投稿 源码网 (https://www.900php.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

尝试连接到Oracle数据库时出现c# – “ORA-01012”错误消息

发布时间:2021-03-06 18:11:50 所属栏目:百科 来源:网络整理
导读:使用C#和Oracle Data Provider for .NET(ODP)我对数据库进行了长时间的查询,然后使用TOAD结束服务器端的连接.之后,随后对数据库的调用,甚至创建新的OracleConnection对象,都会抛出以下错误: ORA-01012: not logged onProcess ID: xxxSession ID: yyy Seri

使用C#和Oracle Data Provider for .NET(ODP)我对数据库进行了长时间的查询,然后使用TOAD结束服务器端的连接.之后,随后对数据库的调用,甚至创建新的OracleConnection对象,都会抛出以下错误:

ORA-01012: not logged on
Process ID: xxx
Session ID: yyy Serial number: zzz

进程ID和会话ID是我用来结束连接的标识符.

看起来当我在服务器端结束与Oracle数据库的连接时,断开的连接将返回到连接池.当C#客户端代码(使用ODP)打开新连接时,可能会检索返回到连接池的断开连接.

有关如何解决此问题的任何想法?

顺便说一下,我正在使用Oracle客户端10

解决方法

我通过将连接字符串中的“Validate Connection”属性设置为true来解决了我的问题.

你可以阅读更多here

作为警告,我引用了Oracle文档.

The Validate Connection attribute validates connections coming out of the pool. This attribute should only be used when absolutely necessary because it causes a server round-trip to the database to validate each connection right before it is provided to the application. If invalid connections are uncommon,developers can create their own event handler to retrieve a new connection,rather than using Validate Connection. This generally provides better performance.

(编辑:源码网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读