problem with JDBC connection

P

prakash.mirji

Hello All,

i am using oracle.jdbc.driver.OracleDriver driver to connect to oracle
database.
And below is my tnsnames.ora file

ora2 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(Host = oracleHost)(Port = 1521))
)
(CONNECT_DATA = (SID = ora1))
)



And in below line code of i use the instance name as ora1, my
connection will establish and i get the required output. However if i
use instance name as ora2 , i get SQL exception which says connection
didn't establish.

// Get a connection to the database
Connection conn =
DriverManager.getConnection( "jdbc:eek:racle:thin:mad:oracleHost.xyz.com:
1521:" + "ora2", "user", "passwd") ;

I can't change ora2 as ora1 because the there are multiple entries in
the tnsnames.ora file which uses SID and outside block name same as
ora1 but its on different oracle host.

My question is :
for jdbc connection , i should use SID as ora1?. Please let me know.

Thanks & Regards,
Prakash
 
S

stefanomnn

Hello All,

i am using oracle.jdbc.driver.OracleDriver driver to connect to oracle
database.
And below is my tnsnames.ora file

ora2 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(Host = oracleHost)(Port = 1521))
)
(CONNECT_DATA = (SID = ora1))
)

And in below line code of i use the instance name as ora1, my
connection will establish and i get the required output. However if i
use instance name as ora2 , i get SQL exception which says connection
didn't establish.

// Get a connection to the database
Connection conn =
DriverManager.getConnection( "jdbc:eek:racle:thin:mad:oracleHost.xyz.com:
1521:" + "ora2", "user", "passwd") ;

I can't change ora2 as ora1 because the there are multiple entries in
the tnsnames.ora file which uses SID and outside block name same as
ora1 but its on different oracle host.

My question is :
for jdbc connection , i should use SID as ora1?. Please let me know.

Thanks & Regards,
Prakash


hi, i should set ora1 in your connection string: host:port:SID, it
doesn't matter name in tnsnames.ora

stefano
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,697
Latest member
AugustNabo

Latest Threads

Top