Thursday, September 4, 2014

How connect to oracle database without using entry in tnsnames.ora?

Lets suppose you want to connect to database service with next description:

HOLE =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.108.1.1)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = hole.service)
    )
  )

Instead of adding it to tnsnames.ora you may write it instead of database name in your application :



If you don't want to write a long description you can use another format:
<host>:<port>/<service_name>

For example:
192.108.1.1:1521/hole.service

It will work as well as first case. Both examples represent the subset of valid oracle connection strings.

Moreover, you can use these connection strings in Oracle API methods instead of TNS names.
For example, one of these methods is OCISessionPoolCreate.

Good luck!





No comments:

Post a Comment