Marc Krisjanous wrote:

> Hi all,
> I have a servlet that executes queries against a database.  The question I
> have deals with servlet multithreading:
>
> Is there any benefit in using the PreparedStatement class in doGet or
> doPost?
>
> eg. Prepared Statement sqlStatement =
> connection.prepareStatement(sqlString);
>
> >From what I remember the PreparedStatement class makes querying the database
> more efficient for every consecutive call after the first call.  However in
> the servlet multithreading world each request is contained within its own
> thread.  The PreparedStatement is created once for each thread.  The
> statement is executed and the thread ends.  There seems to be no reuse of
> the PreparedStatement object since each thread will create its own and
> destroy it.  Is this correct??
>
> Best Regards
>
> Marc
> [...]

Hi :-)  if you want to reuse them,  I guess you can:
     *  use static/instance fields in your Servlet class to refrence them->don't
         use local method fields in service/doGet/doPost to refrence them
     *   or put them outside your Servlet class->in other helping class, and you
         use them in your Servlet class with/without fields for refrencing them.


Bo
De.07, 2000

___________________________________________________________________________
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