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.
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.
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??
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.