Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to make Database Connection reading the 'tnsnames.ora' file ?

 
Kousik Majumder
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Can anybody tell me the standard way to read the tnsnames.ora file and connect to database automatically.
I have the name of the service(i.e TEST from below entry in tns file) , Username and Password.

a samle entry in tnsnames.ora:-


So now I have only the name TEST and I have to connect this DB after reading its host IP(10.5.3.1) and port address(1521).

Please help with code.

Thanks,
Kousik

 
Jhakda Velu
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will need the user name and password
Just the previous post had the details
Connect to Oracle

Intuitively thinking, what all do you need to , say, login to your email?
You need the correct URL, you need user name and password, right?

Jhakda

 
Kousik Majumder
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to know that how could I find the host IP address and PORT number from the tnsnames.ora file after reading that file.
Is there any standard way to find that?

I have the service name(TEST for above example given) only to find the corresponding host IP address and PORT number from the tnsnames.ora file.

Note: I have username and password. Dont bother about that.

Thank you,

Kousik
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15634
46
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you really specifically need the IP address and port number for something else than connecting to the database?

If you want to connect to an Oracle database and you only know the TNS alias as listed in tnsnames.ora, then have a look at this page, especially "3.2.1.2 TNSNames Alias Syntax" on the bottom. It shows you how to connect to an Oracle database if you only know the TNS alias.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic