I want to connect to Oracle (11g) using unixODBC
. I want the connection string ONLY to specify all the database/data-source information, and the ODBC INI files (/etc/odbc.ini
and /etc/odbcinst.ini
) to contain only generic driver info like where to find the '.so' etc. i.e. I want them to be static. I want to do this so that I can get the connection string from the user externally, and connect to the datasource without having to modify any of the INI files or anything other on-disk configuration.
All the examples I saw make me define the server information in /etc/odbc.ini
like this:
[myDSNname]
Driver = OracleODBC-11g
DSN = OracleODBC-11g
ServerName = //xxx.xxx.xxx.xxx:1521/SID_NAME
UserID = my_user
Password = my_pass
Now, I figured out how to get the UserID and Password out into the connection string by adding "UID=my_user;PWD=my_pass"
to the connection string, and I removed them from odbc.ini
. My joy quickly passed when I couldn't find the way to get ServerName
out of odbc.ini
and into the connection string as well. So how do I do this? And is there a way to get rid of the DSN in odbc.ini
altogether, and have just the Driver
from odbcinst.ini
in the connection string, like we are doing for MySQL?
Edit:
Trying any of the connection strings from www.connectionstrings.com that don't seem to require TNS or a DSN, incliuding EZCONNECT
variants, all give me:
[HY000] [unixODBC][Oracle][ODBC][Ora]ORA-12162: TNS:net service name is incorrectly specified
(12162) (SQLDriverConnectW)