tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael-O <1983-01...@gmx.net>
Subject Re: Tomcat7 - ajax and connection pool : "connection closed" despite the use of "validationQuery" and "testOnBorrow"
Date Fri, 05 Apr 2013 11:18:28 GMT
Fist of all, do NOT top post. Use the power of your wondeful mail client.

Am 2013-04-05 13:05, schrieb Jean-Claude Haw-King-Chon:
> I wish to avoid passing the connection through the layers of the
> application (from controller to DAO).
> The controller initialize the connection and must pass it to the Dao
> layer. I don't want to pass the datasource or connection to the business
> layer as a parameter.
>
> Futher, the data source can be different for each user : it's not
> possible to use a static attribute to store the connection or the
> datasource (by example, in a connection factory).
>
> That's why I think that "threadlocal" is the solution for passing the
> connection between 2 non adjacent layers : is it a bad practice?

ThreadLocals have their use cases but must be used with great caution. 
Are you certain that no one else sets the ThreadLocal and you do not 
suffer from race conditions due to missing synchronization?

Michael


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


Mime
View raw message