You are right regarding the first bottle neck.
"Resultset rs = stmt.executeQuery(query);"
This command is validating the query each time it is executed.  Basically you
are executing the same query over and over from scratch.

In a JDBC book I own, it states that the diffrence in speed between a
PreparedStatement and Statement with 2000 iterations is minutes.

Try creating a PreparedStatement and executing that.  While the first time may
be slow, the following calls will be much faster.

DanC

Marc Krisjanous wrote:

> Hi all,
>
> first of all I would like to congratulate everyone within this list for
> making it the most informative source of information regarding Servlets.
>
> Now a question.
>
> Does anyone know or can direct me to site which contains information on
> optimising JDBC connections within a servlet and/or java bean.
>
> We currently have a Java bean that connects to an AS400 db2 database using
> JDBC.  The Java bean is executed by a servlet.  We have this working but the
> response time between executing the sql request and displaying the results
> is far too long - 2000 records with 4 string columns = 1 minute!  We are
> using connection pooling but it still doesn't solve the time lag  problem we
> are having.
>
> We believe there are two major bottle necks:
>
> 1.the majority of the time is spent loading the resultset with the data
> coming back from the AS400.
>
> eg. ResultSet rs   = stmt.executeQuery(query);
>
> 2.Another bottle neck is formatting the result set into objects with which
> we can display the data on the JSP.  For a solution we are thinking of
> extracting only a certain amount of records eg 50 a time and displaying the
> 50.  If the user requests the next 50 then we will extract it from the
> resultset - cycle goes on until all results have been displayed.
>
> Any ideas??
>
> Best Regards
>
> Marc
>
> ___________________________________________________________________________
> 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