• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

can anybody give me an example about this?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic