当我的应用程序尝试建立数据库连接时:
_conn = new OracleConnection(_connString);
_conn.Open();
这是我得到的错误:
Oracle.DataAccess.Client.OracleException occurred
HResult=-2147467259
Message=""
ErrorCode=-2147467259
StackTrace:
at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure, Boolean bCheck, Int32 isRecoverable)
at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, Object src)
at Oracle.DataAccess.Client.OracleConnection.Open()
at MyCorp.Middleware.Common.DataAccess.OracleDataAccess.OpenConnection() in C:\DevProjects\MyCorp\Solutions\MyApp\trunk\Middleware\Common\DataAccess\OracleDataAccess.cs:line 46
InnerException:
这是我的tnsnames.ora:
# tnsnames.ora Network Configuration File: E:\app\oracle\product\11.2.0\dbhome_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.
LISTENER_ORCL =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
(CONNECT_DATA =
(SID = CLRExtProc)
(PRESENTATION = RO)
)
)
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl.sub.mydomain.com)
)
)
这是listener.ora:
# listener.ora Network Configuration File: E:\app\oracle\product\11.2.0\dbhome_1\network\admin\listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = E:\app\oracle\product\11.2.0\dbhome_1)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:E:\app\oracle\product\11.2.0\dbhome_1\bin\oraclr11.dll")
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
)
ADR_BASE_LISTENER = E:\app\oracle
这是配置文件中的连接字符串:
<add name="ConnectionString"
connectionString="Data Source=(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)))(CONNECT_DATA = (SID = orcl)));User Id=testuser;Password=testpwd;"
providerName="OracleODP-11-2.0" />
&#13;
我可以在命令行上使用sqlplus将数据库连接到数据库。
有没有人有任何建议?为什么我的oracle连接失败了?它之前正在工作,我只是不确定我改变了什么导致它现在失败。
答案 0 :(得分:0)
感谢@Fran,感谢您的建议。没有得到我的团队的批准,试图实施托管解决方案。相反,只需使用本机客户端重新安装oracle在新的虚拟机上。