![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Dec 2005
Posts: 57
Rep Power: 0
![]() |
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 |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Mar 2005
Posts: 139
Rep Power: 4
![]() |
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
|
|
|
|
|
|
#3 |
|
Newbie
|
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 .
![]() |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
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 |