Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem connecting to an Oracle DB via TNS.

Status
Not open for further replies.

cardy

Technical User
Sep 5, 2000
33
0
0
GB
What is the syntax for connecting to an Oracle DB using TNS. The only way I have managed to get it to work so far is by including the full description from the tnsnames.ora file for the database I am trying to connect to in the URL e.g.
sqlj.url=jdbc:eek:racle:thin:mad:(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(COMMUNITY=UNIXTCP)(PROTOCOL=TCP)(HOST=kings)(PORT=1521)))(CONNECT_DATA=(SID=cam02dev)))

This entry is called cam02dev (same as the SID) in my tnsnames.ora file so why can't I just say
sqlj.url=jdbc:eek:racle:thin:mad:cam02dev

I've also tried oci8 instead of thin and it still won't connect.

The error message I get is
java.sql.SQLException: No suitable driver
 
you can use :

'_connection = DriverManager.getConnection ( "jdbc:eek:racle:thin:mad:hostname:port:DBname", "user", "password");'

hostname: dns-name or ip-address
port: port of your DB Listener
DB-Name: SID !!! ( not network alias)

but it seems to me you are talking about 2 different things.
first: with this syntax you are going to use the THIN-Driver which in turn does not need a TNS resolve because it is an thin driver.
( which means you would not need a oracle client installation ( no tnsnames.ora !))
the tradeoff of this driver type is that is real slow !

second: you can use an Oracle OCI-Driver ( Oracle Call Interface ) which uses an existing Oracle Client installation ( this means an TNS Connection ).
This Dirver is faster than the thin-driver !

guenter




guenter
guenter.porzer@oekb.co.at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top