如何使用 system.data.oracleclient 为 oracle 创建一个连接字符串,其中包括主机名、实例名称、用户 ID、密码?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6578810/
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
how to make a connection string for oracle that includes hostname, instance name, user id, password using system.data.oracleclient?
提问by Muhammad Taha Khan
I have made a connection string in oracle like:
我在 oracle 中创建了一个连接字符串,例如:
Data Source=hostname;Initial Catalog=IMPORT_UTILITY;User ID=abc;password=123
I want to make the same for oracle. I am using ODBC.
我想为 oracle 做同样的事情。我正在使用ODBC。
can anyone tell me what will be the connection string for oracle that will be equivalent to above sql connection string using odbc?
谁能告诉我 oracle 的连接字符串是什么,它相当于上面使用 odbc 的 sql 连接字符串?
回答by Joe M.
For Oracle 12c R2 and the Instant Client ODBC Driver (version 12.2.0.1.0) the following connection string should work without having to create a DSN and/or a tnsnames.ora file:
对于 Oracle 12c R2 和 Instant Client ODBC 驱动程序(版本 12.2.0.1.0),以下连接字符串应该可以工作,而无需创建 DSN 和/或 tnsnames.ora 文件:
DRIVER={Oracle in instantclient_12_2};DBQ=HOST:PORT/SERVICE_NAME;UID=USERNAME;PWD=PASSWORD
Example ODBC connection string for the Oracle 12c R2 docker image:
Oracle 12c R2 docker 映像的 ODBC 连接字符串示例:
DRIVER={Oracle in instantclient_12_2};DBQ=127.0.0.1:1521/ORCLPDB1.localdomain;UID=sys;PWD=Oradoc_db1 as sysdba