tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jeffery.s.ea...@transport.qld.gov.au
Subject using a datasource connection pool resource with username and password supplied by user
Date Mon, 10 Oct 2005 03:15:23 GMT

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"
crossContext="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"
type="javax.sql.DataSource"
               maxActive="150" maxIdle="30" maxWait="30000"
               driverClassName="oracle.jdbc.driver.OracleDriver"
               url="jdbc:oracle:thin:@rockrsa:1521:rsams"
removeAbandoned="true"
             removeAbandonedTimeout="600" username="jseaton"
password="ring2405"/>

</Context>
_____________________________________________________________________________________________________________

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
when
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.

Regards,


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: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message