File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Want to read values from tnsnames.ora file with JDBC thin driver (Oracle Datasource is solution) Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Reply locked New topic
Author

Want to read values from tnsnames.ora file with JDBC thin driver (Oracle Datasource is solution)

Kacee Saxena
Ranch Hand

Joined: Mar 04, 2008
Posts: 54
Dear Friends,
I want to write a java code that connects with Oracle database using host,pid,address information from tnsnames.ora file using jdbc thin driver. I dont want to hard code any of these values accept SID.

As per my findings,JDBC thin driver doesnt reads these values from tnsnames.ora file.The usual

Class.forName("oracle.jdbc.driver.OracleDriver");
String url = "jdbcracle:thin:@host:port:SID";
Connection conn = DriverManager.getConnection(url, userName, pwd);

doesnt work for me since I have to get host,port values at runtime.

Also as per my understanding OCI driver should be used if tnsnames.ora file needs to be referred by program. I dont want to use OCI since it needs extra installation stuff. I want to make connection with JDBC thin driver only.

So I thought of using OracleDatasource contained in package : oracle.jdbc.pool

I want to know is OracleDatasource is the best way to make connection with Oracle database when tnsnames.ora file needs to be used in my case?

Please reply ASAP as its very urgent for me
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2350

Kacee Saxena wrote:Please reply ASAP as its very urgent for me
You already have another post open for this.


OCUP UML fundamental
ITIL foundation
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32830
    
    4
Thank you for noticing Jan. I presume Scott and Jeanne won't mind me closing this thread.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Want to read values from tnsnames.ora file with JDBC thin driver (Oracle Datasource is solution)
 
Similar Threads
JDBC code for oracle RAC
Multi datasource in websphere
Want to read values from tnsnames.ora file with JDBC thin driver (Oracle Datasource is solution)
read from tnsnames.ora file
jdbc driver