2012-06-13 163 views
4

使用C#和Oracle Data Provider for .NET(ODP)我对数据库进行了长查询,然后使用TOAD结束了服务器端的连接。在此之后,后续调用到数据库,甚至创造一个新的OracleConnection对象时,会引发以下错误:尝试连接到Oracle数据库时出现“ORA-01012”错误消息

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

凡进程ID和Session ID是我用来结束连接标识符。

好像当我结束连接到服务器端的Oracle数据库时,断开的连接返回到连接池。当C#客户端代码(使用ODP)打开一个新连接时,可能会检索到返回到连接池的断开连接。

有关如何解决此行为的任何想法?

顺便说一句,我使用的是Oracle客户端10

+0

为什么杀死TOAD中的连接?为什么不处理C#中的close? – Limey

+0

@Limey所有这些都是因为应用程序在OLTP DB中进行bussines inteligence查询而不是OLAP DB(我无法更改,至少现在不会)。因此,有时尽管进程很长,但用户不会使用“取消选项”,因为应用程序希望系统返回他等待的数据,这就是为什么DBA会终止会话并且应用程序不响应。 –

+0

所以看来你真正的问题是你的查询运行时间很长。你看过改进吗? – Limey

回答

4

我通过设置为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.

+0

谢谢。它帮助:) –

相关问题