问题描述
我看到一个奇怪的间歇性连接失败.我的应用程序运行正常,然后开始引发连接失败异常.必须重置IIS,应用程序才能再次开始工作.我已经能够将一些失败的原因追溯到oracle集群的意外重启,但并不是全部.还有其他人看到过这个问题吗?我已经在网上搜索了,但没有找到任何东西.
I am seeing a strange intermittent connection failure. My application works just fine and then starts throwing connection failure exceptions. A reset of IIS is required before the app will start working again. I've been able to trace a few of the failures back to an unexpected restart of the oracle cluster but not all of them. Has anyone else seen this problem? I've searched the web but haven't found anything.
客户端-Win2003服务器,运行ASP.net 2.0.50727的IIS,代码为VB.NET,通过Oracle Client 10.2.0.1.0进行ODBC连接
Client - Win2003 server, IIS running ASP.net 2.0.50727, code is VB.NET, ODBC connection via Oracle Client 10.2.0.1.0
服务器-Oracle数据库10g企业版10.2.0.4.0版-Linux群集上的64位生产.
Server - Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production on a Linux cluster.
失败:
Attempting connection.Open()
FAILED connection.Open()
Message:
Stack Trace:
at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure)
at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, Object src)
at Oracle.DataAccess.Client.OracleConnection.Open()
at MABridge2._0.debug.Page_Load(Object sender, EventArgs e) in C:\Documents and Settings\xxxx\My Documents\Visual Studio 2008\Projects\xxx\debug.aspx.vb:line 19
Closed connection
代码:
Imports Oracle.DataAccess.Client
Partial Public Class debug
Inherits System.Web.UI.Page
Dim loggingstring As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim connString As New String("Data Source=xxx_rac;Persist Security Info=True;User ID=xxx;Password=xxxxx;")
Using conn As New OracleConnection(connString)
Dim cmd As New OracleCommand()
Response.Write("Attempting connection.Open()" + "<br>")
Try
conn.Open()
Catch ex As OracleException
Response.Write("FAILED connection.Open()" + "<br>")
loggingstring = "Message: " + ex.Message + "<br>" + "Stack Trace:" + ex.StackTrace + "<br>"
Response.Write(loggingstring)
End Try
conn.Close()
Response.Write("Closed connection" + "<br>")
End Using
End Sub
推荐答案
请尝试修改您的代码以处理OracleCommand实例,否则会导致资源泄漏,这可能是导致问题的原因.
Try modifying your code to dispose of your OracleCommand instance, otherwise you will have a resource leak which could be the cause of your problems.
Dim connString As New String("Data Source=...")
Using conn As New OracleConnection(connString)
Using cmd As New OracleCommand()
Try
conn.Open()
Catch ex As OracleException
logger.LogError(ex.ToString())
Throw
End Try
End Using
End Using
这篇关于间歇性vb.net oracle连接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!