"ORA-01012"尝试连接到Oracle数据库时出现错误消息 [英] "ORA-01012" error message when trying to connect to an Oracle database

查看:1687
本文介绍了"ORA-01012"尝试连接到Oracle数据库时出现错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Using C# and Oracle Data Provider for .NET (ODP) I made a long query to the database, then I end the connection on the server side using TOAD. After that, the subsequent calls to the database, even creating a new OracleConnection object, throw the following error:

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

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

Where Process ID and Session ID are the identifiers I used to end the connection.

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

It seems like when I end the connection to the Oracle database on the server side, the broken connection is returned to the connection pool. And when the C# client code (using ODP) opens a new connection, the broken connection that was returned to the connection pool may be retrieved.

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

Any ideas on how to fix this behaviour?

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

BTW I'm using Oracle client 10

推荐答案

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

I solved my problem by setting to true the "Validate Connection" property in the connection string.

您可以在此处

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

As a warning I quote the Oracle docs.

验证连接"属性可验证从中发出的连接 游泳池.仅在绝对必要时才应使用此属性 因为它导致服务器往返数据库以验证每个 连接提供给应用程序之前.如果无效 连接不常见,开发人员可以创建自己的事件 处理程序以检索新的连接,而不是使用Validate 联系.通常,这样可以提供更好的性能.

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.

这篇关于"ORA-01012"尝试连接到Oracle数据库时出现错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆