I am doing several independent sql inquiries in my servlet program, now they are executed one after another, and I found the response was not satisfying,to speed up those inquiries, I am considering to execute them in different threads simultaneously, can anybody show me an example about how to do that, I never did anything about multi-thread before, thank you! P.S. my jdbc driver is oracle.jdbc, and web server is tomcat4.
hi,everyone! I am a greenhorn but I like java <img src="smile.gif" border="0">
You won't get much of an improvement most likelyu unless the server has multiple CPUs dedicated to Oracle and accepts multiple simultaneous queries from a single account.
Start out with optimising your SQL and your JDBC code, in my experience that's usually enough to yield an adequate performance. If queries are complex, precompile them or consider using stored procedures.
Using stored procedure is a good idea. It can return multiple resultsets, so that you do not need to go back to the database again and again.
Just make the connection one time and run all the SQLs, get the resultsets and use them as and when you need.
Also, if the same results are going to be used in concurrent requests, you can store the query results in a Java Bean object with a proper scope.
Joined: Jun 08, 2004
thanks all of you for those great advices! it is my first post here and I think it helps me a lot. so far I can't add any change to the database, it is likely for me to optimize my sql query then, thank you!