设为首页 - 加入收藏 PHP编程网 - PHP站长网 (http://www.52php.cn)- 电商,百科,编程,业界,移动互联,5G,云计算,站长网!
热搜: 专业 娱乐 服务 百度
当前位置: 首页 > 站长百科 > 正文

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

发布时间:2021-05-14 04:07 所属栏目:[站长百科] 来源:网络整理
导读:使用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.

【免责声明】本站内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。

推荐文章
热点阅读