JDBC url for oracle RAC

Posted by Enrico Giurin Thu, 12 Apr 2007 01:07:00 GMT

If you have to connect to oracle RAC (Real Application Cluster) using JDBC with thin driver, the classic url:
jdbc:oracle:thin:@<HOST>:1521:<SID>
doesn’t work and you get the error ORA – 12505.
Instead, you must use this url:
jdbc:oracle:thin:@(DESCRIPTION=(LOAD_BALANCE=on)
(ADDRESS=(PROTOCOL=TCP)(HOST=host1) (PORT=1521))
(ADDRESS=(PROTOCOL=TCP)(HOST=host2) (PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=service)))
If you have an oracle client, like toad, check the tsnames.ora for the correct values of SERVICE_NAME and host.

Posted in  | Tags ,  | 10 comments | no trackbacks

Comments

  1. Avatar Tel Aviv said 362 days later:

    I kept getting this error over and over. I was hoping that a simple copy paste will solve it, as I just got sooooo annoyed from trying to solve it in the last 2 hours… and praise the lord it worked :) Changing the URLs as u stated did the trick and the connection worked flawlessly.

    THANKS A LOT !

  2. Avatar feedogator said 378 days later:

    Thanks Enrico , it is very helpful for me

  3. Avatar Sloey said 462 days later:

    Unfortunately for me even this didn’t work. I’m using a WebSphere 5 server with connection pools on a system with a 9i client connecting to a 10g RAC. When the client didn’t work I tried using jdbc as above, however I still get : Connection not available while invoking method queueRequest for resource jdbc/racserver. I can test the connection successfully but can’t create a pooled connection. J2CA0020E: The Connection Pool Manager could not allocate a Managed Connection: com.ibm.websphere.ce.j2c.ConnectionWaitTimeoutException

  4. Avatar Tú Phạm said 651 days later:

    Thanks alot, this artical help me much

  5. Avatar pmadrid said 693 days later:

    Use this url: jdbc:oracle:thin:@host1^host2:1521:service_name

  6. Avatar Sachin said 818 days later:

    Thanks a lot for the posting.. It helped us to get through

  7. Avatar Kalidass said 1058 days later:

    Some oracle forum posts seems to suggest that there is some issue with DB, but this post really helped.

  8. Avatar Kristyan said 1126 days later:

    Gracias…

  9. Avatar ravi kiran said 1189 days later:

    hi i already tried this method and failed as the connection fails 5/10 times. Please help me out from this problem..Thank you in advance

    you can reach me at majetyravi@gmail.com

  10. Avatar Patrick said 1195 days later:

    This does help a lot. thanks for this. Keep posting such tricks.

Trackbacks

Use the following link to trackback from your own site:
http://www.jugpadova.it/articles/trackback/28454

(leave url/email »)

   Comment Markup Help Preview comment