Search code examples
oracle-databaseconnection-string

How to structure Oracle in OraClient11g_home1 connection string with host, service-name and port


In Oracle, I have a 32-bit driver to connect in my 32-bit ODBC Oracle in OraClient11g_home1.

I want to connect using host, port, service-name, uid, pwd (as I do in Oracle SQL Developer). But the only versions of connection string that I can find use TNSNames.ora, which I can't modify.

For example I found this connection string:
Driver={Oracle in OraClient11g_home1};Dbq=myTNSServiceName;Uid=myUsername;Pwd=myPassword;

But dbq here is a TNS name. How can I modify this connection string to include host, port, and service-name?

Edit:

I also tried this:

"Driver={Oracle in OraClient11g_home1};SERVER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort))(CONNECT_DATA=(SERVICE_NAME=MyOracleSID)));uid=myUsername;pwd=myPassword;"

But I got an error:

[RODBC] ERROR: state HY000, code 12560, message [Oracle][ODBC][Ora]ORA-12560: TNS:protocol adapter error

Solution

  • Please try this:

    'DRIVER={Oracle in OraClient11g_home1};DBQ=x.x.x.x:MyPort/MySID;UID=username;PWD=password'