You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by hns <ha...@yahoo.com> on 2008/03/03 08:14:20 UTC
about DAO
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
--
View this message in context: http://www.nabble.com/about-DAO-tp15798783p15798783.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: about DAO
Posted by Jeromy Evans <je...@blueskyminds.com.au>.
hns wrote:
> InputStream is = getClass().getResourceAsStream("/db.properties");
>
>
Don't include a leading slash unless you really mean the root directory
(which you shouldn't do in a webapp).
Instead, this line:
InputStream is = getClass().getResourceAsStream("db.properties");
will look for the file in the base of the classpath. (eg
WEB-INF/classes/db.properties or in a jar)
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: about DAO
Posted by hns <ha...@yahoo.com>.
i got one file dbconnmannager.java for pooling but it has some error
i know its nt an s2 question but still wait 4 ans
i put in one package connpool
it gives error at specific point
it can not load properties file
--------------------------------------------------------------------------------------------
/**
* Loads properties and initializes the instance with its values.
*/
private void init() {
InputStream is = getClass().getResourceAsStream("/db.properties");
Properties dbProps = new Properties();
try {
dbProps.load(is);
}
catch (Exception e) {
System.err.println("Can't read the properties file. " +
"Make sure db.properties is in the CLASSPATH");
return;
}
--------------------------------------------------------------------------------------------
is there any rule to properties file
--
View this message in context: http://www.nabble.com/about-DAO-tp15798783p15799947.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: about DAO
Posted by Jeromy Evans <je...@blueskyminds.com.au>.
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