Up to this point, I have been storing the username and password in a Vector that I access whenever I need a connection to the Database. When I am done with the connection, I close the connection. I was wondering what would be the problems in cretaing a single connection when the user logs into the database, and just keeping it open for the lifetime of the application running? And then close the connection when the user disconnects from the database.
Joined: Jun 10, 2002
Creating a single connection is not terrible if you have a small scale app, where you know the servlet will only ever be executed one at a time. But as you add more functionality to your application, you will find the need to have more and more connections. And if two users access your connection simultaneously, things might not work well. A better solution is to use 'Connection Pooling'. Then just continue to open and close the connection as if you only had to serve a single page.
Thanks for your reply. However, this is an application, so each user will have their own Connection on their PC. So there is no need to worry about sharing connections or more than one person using a connection at one time.