• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

time for database access

 
Amod Gupta
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2586
11
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the 8 seconds include:
- connection to the database?
- looping over the resulting ResultSet?
- or just executing the sql statement?
 
Amod Gupta
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
connecting as well as looping.
 
Jan Cumps
Bartender
Posts: 2586
11
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic