问题
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