how to make a connection string for oracle that includes hostname, instance name, user id, password using system.data.oracleclient?

僤鯓⒐⒋嵵緔 提交于 2021-02-08 11:23:19

问题


I have made a connection string in oracle like:

Data Source=hostname;Initial Catalog=IMPORT_UTILITY;User ID=abc;password=123

I want to make the same for oracle. I am using ODBC.

can anyone tell me what will be the connection string for oracle that will be equivalent to above sql connection string using odbc?


回答1:


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:

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:

DRIVER={Oracle in instantclient_12_2};DBQ=127.0.0.1:1521/ORCLPDB1.localdomain;UID=sys;PWD=Oradoc_db1 as sysdba


来源:https://stackoverflow.com/questions/6578810/how-to-make-a-connection-string-for-oracle-that-includes-hostname-instance-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!