tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mikolaj Rydzewski <m...@ceti.pl>
Subject Re: Implementing Connection Pooling
Date Thu, 01 Jul 2010 21:44:27 GMT
Andrew Laughlin wrote:
> Notice no username or password entry exists.  Here's the code to get a
> connection:
>
> Context ctx = new InitialContext();
> org.apache.tomcat.dbcp.dbcp.BasicDataSource ds =
> (org.apache.tomcat.dbcp.dbcp.BasicDataSource)ctx.lookup(
> "java:comp/env/jdbc/DB" );
>
> // These must be set before the call to getConnection(), since getConnection
> actually creates the pool.
> ds.setDefaultCatalog( orgID );
> ds.setUsername( orgID );
> ds.setPassword( orgID );
>   
So let's try to run this code:

1. user A performs request, pool is empty, so it's initialized with 
credentials of user A
2. user B performs request, pool is already initialized, user B gets 
connection created with credentials of user A
3. user A releases connection, it goes back to the pool
4. user C performs, request, gets previously released connection

I don't think you like this scenario..


Idea is simple: create one pool for database.

-- 
Mikolaj Rydzewski <miki@ceti.pl>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message