You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Jüri <jy...@rs.ee> on 2002/06/11 12:00:33 UTC
Problem with maintaining a database connection in a session bean
Hi,
I'm trying to build a small pilot application with Struts. My
ultimate goal is a dynamic web application with intensive use of
database.
My database is Oracle 8.
The problem is following:
in 'LoginAction' I set up a database connection
(java.sql.Connection variable) with Oracle database. I "save" it
in the User session bean as a bean-variable. Then I test it in a
jsp-page.
Everything seems to work: the variable containing the database
connection
is created and put into User bean (something like
...setConnection(connection)). The first time the jsp-page works well:
the connection comes from
"conn=user.get_connection()", I can send a select-query to the
database and display the outcome etc. But if I refresh the jsp-page,
then at a certain
moment an error message is displayed:
java.sql.SQLException: Closed Connection
I undestand that the connection gets somehow lost in the session
bean. This happens especially when I test with two parallel sessions
(one from IE and
another from Netscape).
Can anyone help me? Where could the connection go lost?
Thanks,
George.
P.S
I have to save a connection with every session because this way I
can get user info from the database and administer database privileges.
I can't use just
a connection pool and get a connection from there every time I need
something from the database. I have to lock records, maintain
transactions etc.,
so every user/session needs to have an individual database
connection.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>