Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Java JDBC thin connection problems

533377Jul 8 2008 — edited Jul 31 2008
I have an oracle RAC cluster with two nodes. I'm trying to get a JDBC thin connection to the cluster. But I'm having problem trying to connect to the second node only using the ServiceName.

Current setup RAC serviceName = eric,
Node 1 SID = eric1, Virtual IP = 10.1.2.11
Node 2 SID = eric2, Virtual IP = 10.1.2.12


I can connect to either node using the normal jdbc url.

String url = "jdbc:oracle:thin:@10.1.2.11:1521:eric1";
String url = "jdbc:oracle:thin:@10.1.2.12:1521:eric2";

RAC URL:
jdbc:oracle:thin:@(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=TCP)(HOST=10.1.2.11)(PORT=1521))
(ADDRESS=(PROTOCOL=TCP)(HOST=10.1.2.12)(PORT=1521)))
(LOAD_BALANCE=ON)(CONNECT_DATA=(SERVICE_NAME=eric)(SERVER=DEDICATED)))

FYI this works fine. When I run the Java program which executes following query "select instance_name from v$instance" I get eric1 which implies that I'm connecting to the first node. So to force the connection to the second node I remove the first ADDRESS.

When I run the Java program I get the following error:
Error Code: 17002
java.sql.SQLException: Io exception: The Network Adapter could not establish the connection

FYI
If I add in (INSTANCE_NAME=eric2) everything works. In otherwards this URL will work:
jdbc:oracle:thin:@(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=TCP)(HOST=10.1.2.12)(PORT=1521)))
(LOAD_BALANCE=ON)(FAILOVER=ON)(CONNECT_DATA=(SERVICE_NAME=eric)(INSTANCE_NAME=eric2)(SERVER=DEDICATED))))

When I run the program w/ this URL I get eric2 which means it connected to the second node.

I want to do server side load balancing so I can't put in the INSTANCE_NAME otherwise it will pin it to a certain node. Am I doing anything wrong? FYI the tnsnames.ora on node1 and node2 are identical.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 28 2008
Added on Jul 8 2008
6 comments
6,057 views