-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Claudio,

On 5/13/2009 12:35 PM, Claudio80 wrote:
> I need to access to a DB2 database using those 3 different roles in order to
> limite the access to some tables' rows. 
> So i tried to use the PerUserPerUserPoolDataSource in order to use the
> method getConnection(user,pass) not provided in the BasicDataSource but i
> got some problem.

Would you like to post the details of that problem, and maybe we can
help? I personally wouldn't use this approach since IIRC it requires a
separate database connection for /each user/, rather than using roles to
determine which type of connection you get.

> So i decided to define 3 Resource element in the context.xml (one for each
> role) and when i need to create a specific datasource based on the role i
> use cxt.lookup( "jdbc/" + roleName )
> 
> I have 2 question:
> 
> 1) Do you think it is a good solution

Looks good to me.

> 2) It is better have a DAO object with a list of datasource or a list of DAO
> objects (one for each DataSource)

I would do neither. I would have your DAO accept a java.sql.Connection
object OR the JNDI name under which the DataSource can be found. You can
pass that information either via a parameter to some method like
getProductById(String dataSourceName, Integer id) or by using a
ThreadLocal so you don't pollute your method signatures.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkoSsXkACgkQ9CaO5/Lv0PC48gCdE8hLDZEup0rAh9fGghT6plaS
QhEAn2wP0xtU2Za3FBUZc4K/83JfPHOX
=+VC6
-----END PGP SIGNATURE-----

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

Reply via email to