使用 SID 的 Oracle EasyConnect 连接字符串?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4650014/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Oracle EasyConnect connection string using a SID?
提问by Jon Kruger
I'm trying to connect to an Oracle database through code (Ruby/DBI, but that's irrelevant) using an EasyConnect connection string. All of the Oracle documentation says to specify the connection string as //hostname:port/service_name. I don't have a service_name for the database that I need to connect to, I have a SID instead. Is there a way to create an EasyConnect connection string using a SID instead of a service name?
我正在尝试使用 EasyConnect 连接字符串通过代码(Ruby/DBI,但这无关紧要)连接到 Oracle 数据库。所有 Oracle 文档都说要将连接字符串指定为 //hostname:port/service_name。我没有需要连接的数据库的 service_name,我有一个 SID。有没有办法使用 SID 而不是服务名称来创建 EasyConnect 连接字符串?
My connection code looks like this:
我的连接代码如下所示:
DBI.connect("DBI:OCI8://localhost:9000/the_sid", "username here", "password here")
DBI.connect("DBI:OCI8://localhost:9000/the_sid", "username here", "password here")
I keep trying different things, and depending on what I try, I get one of two error messages:
我一直在尝试不同的事情,根据我的尝试,我收到以下两个错误消息之一:
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor (DBI::DatabaseError)
ORA-12154: TNS:could not resolve the connect identifier specified (DBI::DatabaseError)
回答by DCookie
Did you try the SID as the SERVICE name? You can usually specify a SID where a service is asked for. SERVICE_NAMES typically defaults to the SID. At a SQL command prompt, enter:
您是否尝试将 SID 作为 SERVICE 名称?您通常可以指定请求服务的 SID。SERVICE_NAMES 通常默认为 SID。在 SQL 命令提示符下,输入:
SQL> show parameter service
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
service_names string sid
SQL>
The value(s) in the VALUE column is/are the service name(s) the database is registered as.
VALUE 列中的值是数据库注册为的服务名称。