我有个令人沮丧的错误。我正在从Winforms应用程序和Asp.net页面连接到Oracle (或试图连接)。
Winforms -没问题,Asp.Net -很多问题。
我正在获得的错误(从IIS运行)是:
ORA-12545: Connect failed because target host or object does not exist对我来说,这条消息可能意味着我的连接字符串错了,或者Oracle关闭了,或者防火墙问题,但是我使用的连接字符串和代码与Winforms在同一台机器上使用的连接字符串和代码相同。
有没有其他的想法会导致这个错误?
失败的代码:
string conn = "User Id=172.xx.xx.xxx ;Password=xxx;Data Source=(DESCRIPTION= (ADDRESS=(PROTOCOL=TCP)(HOST=xx)(PORT=1521)) (CONNECT_DATA=(SID=xxx)));
OracleConnection oc = new OracleConnection(conn);编辑:
全栈:
ORA-12545: Connect failed because target host or object does not exist
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Oracle.DataAccess.Client.OracleException: ORA-12545: Connect failed because target host or object does not exist
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[OracleException (0x80004005): ORA-12545: Connect failed because target host or object does not exist]
Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure, Boolean bCheck) +1563
Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, Object src) +59
Oracle.DataAccess.Client.OracleConnection.Open() +4899
UDWWeb.Pages.Availability.Button1_Click(Object sender, EventArgs e) +49
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563发布于 2013-09-20 08:31:08
首先,执行以下检查:
1.) making sure that your listener is running (lsnrcrl stat)
2.) testing connectivity with ping, and then tnsping.
3.) verifying connectivity via the DNS (e.g. /etc/hosts)
4.) make sure to check your tnsnames.ora parms.确保正确输入了ADDRESS参数;最可能不正确的参数是节点名。确保服务器的可执行文件存在。如果协议是TCP/ IP,请编辑TNSNAMES.ORA文件以将主机名更改为数字IP地址,然后再试一次。
最后,再次检查您的ConnectionString。例如,当使用asp.net时,它的格式如下所示。( Web.config示例)
<add name="OracleConnectionString"
connectionString="Data Source=OracleServer1;Persist
Security Info=True;Password="******";User ID=User1"
providerName="System.Data.OracleClient" /> http://msdn.microsoft.com/en-us/library/92ceczx1%28v=vs.85%29.aspx详细解释。
发布于 2013-09-20 08:23:55
而不是在数据源中提供这样的Tns。将其放入(Oracle文件夹) -> product> network -> admin -> tnsnames.ora文件中。
然后,您可以像使用Sql数据源一样使用OleDbConnection。例如:
Provider=OraOLEDB.Oracle.1;Password=***;Persist Security Info=True;User ID=***;Data Source=DataSource_Name_in_TNS_File发布于 2014-11-06 17:30:19
我也有同样的问题,应用程序在我的本地PC上运行,但是当我把它上传到服务器上时,我得到了相同的错误。
我只是通过在连接字符串中写入完整的主机名来解决这个问题,例如host=abcd.exchange.com。不要写一个像host=abcd这样的短名字。
https://stackoverflow.com/questions/18911853
复制相似问题