• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Passing user and password in Oracle RAC url

 
Chase Bonham
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have to connect to oracle RAC (Real Application Cluster) using JDBC with thin driver, the classic url:

jdbcracle:thin:@<HOST>:1521:<SID>

doesn�t work and you get the error ORA � 12505.
Instead, you must use this url:

jdbcracle: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?
 
Jan Cumps
Bartender
Posts: 2599
12
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Gaurav Chikara
Ranch Hand
Posts: 412
  • Mark post as helpful
  • send pies
  • 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>jdbcracle:thin:@10.6.110.155:1521:Q5LUCIL</value> <--Put your URL here
</parameter>
<parameter>
<name>user</name>
<value>redb_52_dev</value>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic