struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeromy Evans <jeromy.ev...@blueskyminds.com.au>
Subject Re: about DAO
Date Mon, 03 Mar 2008 07:27:57 GMT
hns wrote:
> i have use ms access database
> i have set in login.java that if user is valid then username and userid and
> connection object is stored in session
> now this connection object i have pulled in entire session to workout with
> common object
> is this good for security and performance?
> I little bit worry about it 
>
>
>   

No, it's not good to store a connection object in the session.  Treat 
the connection as a scarce resource. If you hold a connection in a 
session the resource is wasted and you risk running out.

Either;
a. open a connection for each request and close it at the end of the 
request  *every time*; or
b. use a connection pool

The latter manages the connections for you, allocating you one when you 
need it, but managing them in a sensible way (eg. keeping the connection 
open but allocating them exclusively for request).

Connection Pooling for Microsoft Access:
http://support.microsoft.com/kb/169470

With JDBC:
http://java.sun.com/developer/onlineTraining/Programming/JDCBook/conpool.html

Via Tomcat:
http://www.onjava.com/pub/a/onjava/2006/04/19/database-connection-pooling-with-tomcat.html


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message