File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes can anybody give me an example about this? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "can anybody give me an example about this?" Watch "can anybody give me an example about this?" New topic

can anybody give me an example about this?

Jianwei Yao

Joined: Jun 08, 2004
Posts: 2
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">
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
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

Joined: Jan 22, 2004
Posts: 185
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.

Siyaa Hoffman

Joined: Jan 15, 2004
Posts: 23
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

Joined: Jun 08, 2004
Posts: 2
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!
I agree. Here's the link:
subject: can anybody give me an example about this?
It's not a secret anymore!