Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can anybody give me an example about this?

 
Jianwei Yao
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
danny liu
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Jeroen.

My suggestions are:

a. Tune the Oracle database parameters or give it more resources.
b. Optimize the your query.
c. Use Database Connection Pool instead of acquiring a new connection everytime.

dan
 
Siyaa Hoffman
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jianwei Yao
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic