• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Passing user and password in Oracle RAC url

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)))

How do I pass the username/password in this RAC url?
 
Bartender
Posts: 2662
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try Connection con = DriverManager.getConnection(url, "user", "password");

Read What�s New for Java DB, JDBC, and Database Web Services in Oracle Database 10g, page 12 for instructions from the vendor. You can strip away the non-essential code.

Take care: Oracle advises you to use their proprietary OracleDataSource, and to import oracle.jdbc.pool.*. Once you got the code working, it might be a good exercise to see how you can switch to the standard java interfaces.

Regards, Jan
[ July 03, 2007: Message edited by: Jan Cumps ]
 
Chase Bonham
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Unfortunately, this is not a programmatic call. I'm trying to configure Tomcat 5.5 to use an Oracle RAC database for session replication and the configuration tags provide only one attribute on the tag. That attribute is
connectionURL.

<Store connectionURL="">

</Store>

I need to be able to specify everything about that database in that one URL.
I know I can specify the long winded RAC url, but not sure how to fit in the username and password.

Apparently, in the mysql, postgress world putting username, passwords in JDBC urls is very common, probably why Tomcat developers didn't see the need to provide username/password.
 
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

How do I pass the username/password in this RAC url?



Since You are using tomcat you can easily pass user name password inside the context xml file where you define the jdbc url also


e.g.
<parameter>
<name>url</name>
<value>jdbc:oracle:thin:@10.6.110.155:1521:Q5LUCIL</value> <--Put your URL here
</parameter>
<parameter>
<name>user</name>
<value>redb_52_dev</value>

 
A sonic boom would certainly ruin a giant souffle. But this tiny ad would protect it:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic