Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 24th, 2007, 12:23 PM   #1
metsfan
Programmer
 
Join Date: Dec 2005
Posts: 57
Rep Power: 0 metsfan is an unknown quantity at this point
JDBC question

I am currently making a website using java with tomcat

As anyone who has used tomcat/servlets knows, each java page gets called every time you run a new page. My problem is that i have a page which uses a database, and every time i run the page, it has to reconnect to the database. is there any way to make it so that the connection is "open", that is no matter how many times i go to this page, i never have to reconnect.

BTW, i am using postgresql and JDBC v.4
metsfan is offline   Reply With Quote
Old May 21st, 2007, 4:20 PM   #2
paulchwd
Hobbyist Programmer
 
paulchwd's Avatar
 
Join Date: Mar 2005
Posts: 139
Rep Power: 4 paulchwd is on a distinguished road
Well if you are using a servlet you could handle the connections in the init() method which is called only once in the servlets life (when it is first accessed) but that is not wise, it is better to do any database connections in the doPost() / doGet() methods
paulchwd is offline   Reply With Quote
Old May 29th, 2007, 11:58 AM   #3
msi_333
Newbie
 
msi_333's Avatar
 
Join Date: May 2007
Location: Egypt
Posts: 19
Rep Power: 0 msi_333 is on a distinguished road
Send a message via Yahoo to msi_333
connection

I think that you have to connect to the database every time , because the "connection" object needed in every servelts page and you should close the connection to the database when u finish ur query in the page and also close the statement object ... using the close() function. I don't know why u considered it as a problem .
msi_333 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Virtual pet site MySQL question proudnerd PHP 6 May 13th, 2006 7:22 PM
Attitudes Oddball Coder's Corner Lounge 29 Mar 18th, 2006 9:34 PM
How to post a question nnxion C++ 10 Jun 3rd, 2005 11:53 AM
How to post a question nnxion C++ 0 Jun 3rd, 2005 8:55 AM
How to post a question nnxion C 0 Jun 3rd, 2005 8:55 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 8:56 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC