permaculture playing cards*
The moose likes JDBC and the fly likes time for database access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "time for database access" Watch "time for database access" New topic
Author

time for database access

Amod Gupta
Greenhorn

Joined: Oct 16, 2009
Posts: 28
I am accessing a database in MS Access using JDBC from my java program.The Ms Access Database has 1000 records.Now for each query it takes about 8 seconds.Is it normal?
I mean that is it not taking more time and how can I reduce this time.Thank you.
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2497
    
    8

Does the 8 seconds include:
- connection to the database?
- looping over the resulting ResultSet?
- or just executing the sql statement?


OCUP UML fundamental and ITIL foundation
youtube channel
Amod Gupta
Greenhorn

Joined: Oct 16, 2009
Posts: 28
connecting as well as looping.
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2497
    
    8

A few things:


- You can create a connection at the start of your program, and keep using it.
- Check if you really need to loop over 1000 records. Can't you query a subset? You seldom need to retrieve 1000 records in a program.
- what are you doing inside your "while ( ResultSet.next())" loop? You are running that code 1000 times.

Check how long the executeQuery() line in your takes.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: time for database access