Oracle客户端+与 .NET 的 TNSless 连接
我们使用 System.Data.OracleClient 和抽象基类 DbConnection、DbCommand 等来连接到 Oracle。
在我们的开发阶段,这种连接工作得很好。在登台期间,我们遇到错误 ORA-12514:TNS:侦听器当前不知道连接描述符中请求的服务。
我们的目标是在没有 TNS 条目的情况下进行连接,并在连接字符串 (www.connectionstrings.com/oracle#19) 中提供所有相关信息,
我可以确认 SQL plus 将从临时服务器(侦听器)连接到所需的架构正在听)。连接到 SQLPlus 的 TNS 条目与正在构建的查询字符串的所有凭据相匹配。
SERVER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort))(CONNECT_DATA=(SERVICE_NAME=MyOracleSID)));uid=myUsername;pwd=myPassword;
我们错过的服务器上是否有安装?我们可以调整一些东西吗?
任何帮助表示赞赏。
We are using System.Data.OracleClient and the abstract base classes DbConnection, DbCommand (etc) to connect to Oracle.
The connection works fine in our development stages. During staging we encounter the error ORA-12514: TNS:listener does not currently know of service requested in connect descriptor.
Our goal was to connect without a TNS entry, and providing all the relevant information in the connection string (www.connectionstrings.com/oracle#19)
I can confirm that SQL plus will connect to the desired schema from the staging server (the listener is listening). The TNS entry hooked into SQLPlus matches all the credentials of the query string being built.
SERVER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort))(CONNECT_DATA=(SERVICE_NAME=MyOracleSID)));uid=myUsername;pwd=myPassword;
Is there an installation on the server we missed? Something we can tweak?
Any help is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
SID 不是服务名称。服务名称通常是完全限定的数据库名称,而 SID 是短标识符。
服务名称可能是 dbname.company.com,而您的 SID 是 dbname。一个实例实际上可以有多个与其关联的服务名称,但只能有一个 SID。
将连接字符串中的 SERVICE_NAME 更改为 SID,或为 SERVICE_NAME 选项指定服务名称。
A SID is not a Service Name. A service name is usually a fully qualified database name, while a SID is a short identifier.
A service name might be dbname.company.com while your SID is dbname. An instance can actually have several service names associated with it, but only one SID.
Change your SERVICE_NAME to SID in your connect string, or specify your service name for the SERVICE_NAME option.
如果我没记错的话,我遇到了同样的问题,直到我改用 Oracle 提供程序以及 OracleDbConnection 和 OracleDbCommand。通用提供者并不总是在所有情况下实例化正确的提供者。
If I recall correctly, I had the same issue until I switched to using the Oracle providers and OracleDbConnection and OracleDbCommand. The generic ones don't always instantiate the correct provider in all cases.
如果您的 Oracle 客户端版本为 10+,您还可以使用 EZCONNECT (代表 < a href="http://download.oracle.com/docs/cd/B19306%5F01/network.102/b14212/naming.htm#ABC524382SRI12" rel="nofollow noreferrer">Easy Connect 命名方法) 。您的连接字符串将如下所示:
结合 Oracle Instant Client,它让Oracle的使用感觉近乎专业!...
If your Oracle client is in version 10+, you could also use EZCONNECT (which stands for Easy Connect naming method). Your connection string would then look like this :
Combined with Oracle Instant Client, it makes the use of Oracle feel almost professional !...
Microsoft 已弃用
System.Data.OracleClient
。请参阅这篇文章。
Microsoft deprecated the
System.Data.OracleClient
.See this post.