File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Doubt in JavaServerPages and in JavaBeans??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Doubt in JavaServerPages and in JavaBeans???" Watch "Doubt in JavaServerPages and in JavaBeans???" New topic

Doubt in JavaServerPages and in JavaBeans???

Kumaran Sowrirajan
Ranch Hand

Joined: Oct 15, 2001
Posts: 36
Hi friends
I am having 5 jsp pages.each jsp page contains
one Javabeans in which database
connection and relevant results are fetched from the database and the results are returned to
the corresponding jsp if i succesffuly logged into my application then for each jsp
page i am accessing the javabeans which will connect to the database connection and return the
valid results.this will make the response slow.
[i think for each request i am opening the database connection and fetch the results and
return the results to the corresponding jsp page and close the database connection this will
make the response time i correct???]
What i want to know is how can i make the database connection open whenever the user session
starts and connection remains open until the session is valid for the particular user.suppose
if the session is invalid then the database connection should be closed.
[bcos now if you access any jsp pages then the response time is quick compared to previous one.]
I dont want to open a database connection everytime if i am accessing the jsp page and closed
after the user leaves the page?is it possible thro' connection pooling???
I am using jdbc-odbc driver to connect to the it possible to do like that???
if so...then plz tell me how to do that one???
Also which one is best to access the database records???Servlets or in JavaBeans and why?
Also i am coming across one more problem which is better to use???Vector or Hashtable to fetch
the records from the database.more accurately which is faster?i know Vector is synchronized so
it is not faster compared to arrays.then is there any java.util.collection is there to increase
the fetching the data very fastly.
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
No offense, but that was a very lengthy post!
Just a friendly suggestion, try to ask what you want in a precise way. If someone needs more info they sure will ask. Secondly, please don't post too many qstns in one post. One thing at a time, is good.
You can create a DB connection and instantiate it as a bean on the session object. Its quite possible.
To access the db records, I personally prefer a bean rather than a Servlet. Having a bean is easy to test/debug the DB portion of your software. You can do it with a stand alone application without other dependencies.
Vector verses Hashtable....ummmm....doesn't matter. Both are synchronized.
- madhav

Take a Minute, Donate an Hour, Change a Life
I agree. Here's the link:
subject: Doubt in JavaServerPages and in JavaBeans???