This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes Database - how to increase the access time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Database - how to increase the access time" Watch "Database - how to increase the access time" New topic
Author

Database - how to increase the access time

Jas Oberai
Ranch Hand

Joined: Jan 16, 2005
Posts: 231
Hi friends,
I have this simple class,which takes in query and returns the results.I don't know why the access is slow and it take(5-10 seconds) giving back the results.I don't know much about connection pool,can u just have a look at this simple class,and tell me if there's anything on which i can improve upon and where to add the(*.close() statements).The same query runs instantly if i make a php program.



Any help would be appreciated.


SCJP 1.4 (88%)<br />SCWCD 1.4 (88%)
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30057
    
149

Jas,
First thing is to see where the time is going. Try inserting some System.out.println() statements after each step to see if the time is to get the connection or run the query. We may be able to help more if you post the query/SQL too. The close statements go wherever you are done with processing the resultset.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Jas Oberai
Ranch Hand

Joined: Jan 16, 2005
Posts: 231
Thanks Jeanne,
I am running different normal queries,but the php code shows me the results instantly.I just need help in closing the connections and opening them in an optimised way.Most probably they are causing the delays i guess.I am opening too many connections.Can you help me now??
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30057
    
149

Jas,
I still think you need to see whether it is the query taking all the time or something else. Add some timing code as shown below. It is possible that PHP processes queries differently. Especially if the query contains "select *".

I can't just point you at where you need to close the connection because it depends on the calling code. You could add a close method to this class. Then the calling code can call that method after the resultset is processed. If you need more help on where to close the connection, show a sample client/caller for this class.
 
jQuery in Action, 2nd edition
 
subject: Database - how to increase the access time
 
Similar Threads
problem connecting to postgres 8.2.3
Statement Closed Error - please help
Ned to change servlet code to pure java
Reuse an object?
Unhandled event loop exception due to NullPointerException