aspose file tools*
The moose likes JDBC and the fly likes Passing user and password in Oracle RAC url Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Passing user and password in Oracle RAC url" Watch "Passing user and password in Oracle RAC url" New topic
Author

Passing user and password in Oracle RAC url

Chase Bonham
Ranch Hand

Joined: Jul 15, 2006
Posts: 50
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

Joined: Dec 20, 2006
Posts: 2503
    
    8

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 ]

OCUP UML fundamental and ITIL foundation
youtube channel
Chase Bonham
Ranch Hand

Joined: Jul 15, 2006
Posts: 50
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

Joined: Jun 09, 2000
Posts: 410
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>


SCJP,SCWCD,SCBCD<br />If Opportunity doesn't knock then build the door
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing user and password in Oracle RAC url