× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Ok thanks.  I'll do that.

Ron Power
Programmer
Information Services
City Of St. John's, NL
P.O. Box 908
St. John's, NL
A1C 5M2
709-576-8132
rpower@xxxxxxxxxx
http://www.stjohns.ca/
___________________________________________________________________________
Success is going from failure to failure without a loss of enthusiasm. - 
Sir Winston Churchill




"Clapham, Paul" <pclapham@xxxxxxxxxxxxx> 
Sent by: java400-l-bounces@xxxxxxxxxxxx
2006/05/04 03:13 PM
Please respond to
Java Programming on and around the iSeries / AS400 
<java400-l@xxxxxxxxxxxx>


To
"Java Programming on and around the iSeries / AS400" 
<java400-l@xxxxxxxxxxxx>
cc

Subject
RE: Connection Pooling






The DAO thing is definitely a good idea, but not so much because of 
thread-safety. Its main benefit is that you can close your database 
connections (i.e. return them to the connection pool) faster and more 
reliably. Database connections are a scarce resource. So yes, you should 
use them.

But your servlet still isn't thread-safe. You have a lot of instance 
variables (and static variables too) such as "dsname" which are shared 
between all users of the servlet. They aren't necessarily thread-safe. It 
looks to me as if some of them are set up in the init() method, so they 
are essentially constants. Those aren't a problem. But others like "dmd" 
are set up anew for each query, so they are a problem. If you can make 
them local variables in the method where they are used, that would be the 
best. Or if they are used in several methods, then pass the data around as 
parameters to those methods.

Regards
PC2

-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx 
[mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of RPower@xxxxxxxxxx
Sent: May 4, 2006 10:18
To: Java Programming on and around the iSeries / AS400
Subject: Re: Connection Pooling

Ok,
I've done some reading and stuff on how to handle database records and I 
think I got it now, but I want someone to verify my thoughts.
Instead of accessing my result sets and record processing through the 
servlets, because they are multithreaded, I'm better off creating a DAO 
class for each table and using instantiated classes of that because 
instantiated classes are thread safe yes?  My code follows for a simple 
servlet that saves a new softwareName.  Thus I shouldn't get two different 
threads changing the variables in each one as it goes thru.  Thanks,


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.