It's not a secret anymore!
The moose likes JDBC and Relational Databases and the fly likes Problem with jakarta commons dbcp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Problem with jakarta commons dbcp" Watch "Problem with jakarta commons dbcp" New topic

Problem with jakarta commons dbcp

Sunetra Sen
Ranch Hand

Joined: Feb 17, 2005
Posts: 43
I use sybase as the database for my db.For establishing connections I use the Jakarta commons Dbcp.The database URL,username and password are stored in the jocl file like this:

<object class="org.apache.commons.dbcp.PoolableConnectionFactory" xmlns="">
The first argument to PoolableConnectionFactory is a ConnectionFactory.
We'll use a DriverManagerConnectionFactory, passing in the appropriate
connect string for the underlying driver.
<object class="org.apache.commons.dbcp.DriverManagerConnectionFactory">
<string value="jdbc:sybase:Tds:"/>
<string value="enh_find_update"/>
<string value="m0zart"/>

And I establish connection by:
Connection conn = DriverManager.getConnection("jdbc:apache:commons bcp:/aolintlDevDriver");

Now i want to invoke a perl script from my servlet and pass the values of the databasename,username and password to the perl script.
The problem is how to get the password in the servlet code so that I can pass it to the perl script.
I can get the database name and the user name by geting the DatabaseMetaData object from the connection object.But the password is the one whose value I cannot access.
Please tell me how i can do that?

Thanks in advance,
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33124

You can read in the XML file and use a parser to get the password.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
Or another suggestion is to define all of these as name/value paramenters in the application's web.xml i.e.

I agree. Here's the link:
subject: Problem with jakarta commons dbcp
It's not a secret anymore!