PDA

Click to See Complete Forum and Search --> : Servlet maintaining a JDBC connection?


Cudabean
Apr 11th, 2002, 06:18 PM
Hi,

I think I can probably figure out to do this, but wanted some implementation opinions. I need to set up a 'secure' system that maintains a temporary connection to a database via a servlet. I think it would be a neat design where when a user succesfully logs on, a JDBC connection is created with a specified inactivity time-out. In this way several users could be logged on and can interact with the database independently.

How do I implement this?
I suppose one way to go would be to set up a session variable that has a connection, then when other classes, servlets and jsp's need to use the connection, they could consult the session variable based on the users "sessionid" or whatever they call it in the Servlet realm. I kind of like that because each session has a built in inactivity time-out.

Opinions?

Many Thanks,

cudabean

Cudabean
Apr 18th, 2002, 02:59 PM
This approach is working well. The one thing I like about JSP and Servlets as opposed to ASP and others is the ability to 1, define an object and 2, make it a session variable.

cudabean