Thursday, August 22, 2013

A TNS-Nameless Connection!


This week we have been rolling out our new web application and late one evening long after our server administrator had signed off, I realized that while the Oracle client had been successfully installed on a server, the tnsnames.ora file had not been configured.

To add to my frustration, I didn't have rights to edit the file and needed to test database connectivity and verify that a view I had created to use the USERENV/HOST variable via the SYS_CONTEXT function was able to successfully differentiate inbound requests and return the appropriate data based on originating server - which of course meant I needed to test from that server in particular.

I discovered that SQL*PLUS does allow for a tnsnames-less connection by directly specifying the entry when connecting.  Below is an example of what I used to connect from the command line on the server:
sqlplus user/pw@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=myhostname.domain.com)(PORT=1521)))(CONNECT_DATA=(SID=proddb)))
This allowed me to get around not having admin rights for the Oracle client installation.  Too cool.

No comments:

Post a Comment