-- you wrote --
>Hello All,
>I need some help regarding multiuser programming using Servlet. We >have
>developed an application which runs as follows
>
>HTML ----> Servlet----->
Database(MS Access)
>HTML <---Servlet<-----
>
>The problem here is that we are opening just one connection to the
> >database in the init() of the servlet and using the same connection >for
>any request coming from any user.
***
This access path is very common for servlet based (or any CGI based) 3-tier
application as such. Using a single connection for n requests is a bad idea
- performance wise. Smart connection pooling can be a way to go. Either you
do it yourself (isnt that hard) or if you are using any application server,
use the service provided by those servers thru your servlet.
***
>This could led to problems of data corruption such as variable >getting
>changed before the query which uses it gets executed (This >would happen if
>two users access the servlet at the same time).
>The two solutions known to handle this problem are syncronising or >using
>SingleThreadModel. But both these methods have their >drawbacks. Also
>these handle multithreading aspect rather than >multiuser. Is there any
>third way to handle this kind of a multiuser >aspect.
****
Any multi-threaded application is potentially risking data corruption/
deadlock issues ! And multiuser aspect is no different from multithreading -
you dont spawn multiple processes for multiple users ! So its necessary that
you use smarter, thread-safe mechanism in your servlet(s) to receive user
connnections, access the DB, and respond.
The first part is almost always provided by the webserver / servlet engine
implementing the servlet API. The later part of DB connection handling can
be very well be designed using DB connection pooling - a topic very easily
found in any servlet book / CGI book !
****
hope it helps ..
Shashank
_______________________________________________________________
Get Free Email and Do More On The Web. Visit http://www.msn.com
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html