I have set up a connection pool using the following set up:

<?xml version="1.0" encoding="iso-8859-1"?>
    Context configuration file for the Road Safety Audit Management System
Web App

<Context path="/RSAMS" docBase="RSAMS" debug="1" reloadable="true"
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_rsams_log." suffix=".txt" timestamp="true"/>

   <!--the RSAMS resource for connection pooling -->
   <Resource name="jdbc/rsams_oracle" auth="Container"
               maxActive="150" maxIdle="30" maxWait="30000"
             removeAbandonedTimeout="600" username="jseaton"


to access this pool I use the following code:

Context initContext = new InitialContext();
Context envContext  = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/rsams_oracle");
conn = ds.getConnection();

It all works fine:

But what I really want to do is to get a database user and password from
the user and (after validating it) write this to a session cookie.
Then when the user interacts with the database (which is all the time) the
username and password will be extracted
from the cookie and used in the following way:

Context initContext = new InitialContext();
Context envContext  = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/rsams_oracle");
conn = ds.getConnection("username","password");

The problem is I have not been able to find a way to get this to work.

I have tried removing the user and password from the connection pool
resource (doesn't work)
I have tried this code in the calling - conn =
ds.doGetConnection("username","password") - Doesn't work.

I thought javax.sql.datasource which is the type of the resource supported
the getConnection(username, password) method but it doesn't seem to work
using a resource set up as above.

If anyone can point me in the right direction I will be most grateful.  I
have trawled the forums with no success as everyone seems to be
happy with the username and password being set in the context resource.

Any help I can get would be most appreciated.


Jeffery S. Eaton

Opinions contained in this e-mail do not necessarily reflect
the opinions of the Queensland Department of Main Roads,
Queensland Transport or Maritime Safety Queensland, or
endorsed organisations utilising the same infrastructure.
If you have received this electronic mail message in error,
please immediately notify the sender and delete the message
from your computer.

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to