Hi Mirko -

We usualy open a pool of database connections in the servlet's
init() method.  Use a connection pooling object - there's probably
plenty available.  The servlet's service() method executes in a
seperate thread for each request.  so, inside the service() method,
you can grab a connection from the pool and do your database operations.

-roger

> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Date: Fri, 9 Apr 1999 16:51:29 +0200
> From: Mirko Wolf <[EMAIL PROTECTED]>
> Subject: a design question
> To: [EMAIL PROTECTED]
>
> Hi there,
>
> Here is another question how to design functions for a servlet.
> IMHO for every request made to a servlet the service function is called again.
> But what happens, when a critical function  is called by two or more service
functions at the same time?
> For instance a function which handles a database connection and the belonging
queries.
> What happens, when a second service function call this method while it
handle's a database querie for the first one?
> The first one will have no chance to complete the request, right?
> Should the database function synchronized or is it better to implement the
SingleThreadModel?
> I think it is easier to implement the SingleThreadModel, because i've a lot of
functions the must be synchronized and
> then i'am afraid to have a deadlock in the system.
> Any comments or suggestions?
>
>                 Mirko
>
> ___________________________________________________________________________
> 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

___________________________________________________________________________
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

Reply via email to