Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Ricky Johnson   on May 12 In Java Category.

  
Question Answered By: Herbert Weaver   on May 12

It appears to me that going back  an "connecting" to the database  is
your log jam. It would be best to create an SQL Join on the "other"
information you have to get as you iterate through the resultset.

From your description, you get the result set, then as you process
each record, you have to go back to the database to get more
information. If you are "connecting" to the database for each data
request, then you are spending ALOT of time getting and releasing
connections and that can be very costly. IF YOU CANNOT DO AN SQL
Join, then you might want to share the connection you got for the
first query with all subsequent connections. You do not have to
close the connection every time you do an SQL call, each "Statement"
can use the same connection, Pass it in as a parameter to the method
doing the next getting of the information.

You might also want to check "WHERE" the log jam is by using a Log
and logging the start and end time in specific areas (entrance into
and exit from certain methods... the start of I/O the end of an
I/O... the start of your result set processing... etc). Or you could
use

System.out.println("Entered such and such a method: " + new
java.util.Date());

as a logging method to the console....

But I think your reall problem  is too much database access. It
appears quick when you have a few records, but as you scale into the
hundreds and thousands of records, you have a problem. Look at the
design of your database and use "joins" effectively to get just "ONE"
result set. Then, you don't have to revisit the database and scaling
to a larger record  load is not as time consuming...

Share: