Hi, I wish to know whether a database session can be terminated earlier than web session which is binding the database session. The database session is bound to the web session upon database login by: 1. javax.servlet.http.HttpSessionBindingListener; 2. javax.servlet.http.HttpSessionBindingEvent; Both the database session and web session are set to timeout in 60 minutes. When we do an experiment to manually terminate the database session after 30 minutes, our expected result is that no record can be added to the database from the web application after 30 minutes. We test this because there is a possiblility that the database session may end earlier than web session for unknow reason. But our test result shows that record still can be added to database after 30 minutes. 1. What is the cause of this unexpected result ? 2. What is the supposed result ?
I'm puzzled by what you are doing here. You say The database session is bound to the web session upon database login. Do you mean that a JDBC Connection is created when a user logs in to the web application? If so, where do you store this Connection object, and how do you use it? Can you please explain in a bit more detail how you access your database from your Java code?
Here is my wild guess. You have bound the Connection object to the Session, which I don't see how you do this, but anyway, as with JNDI, you bound a reference to the object is a "HashMap" of some sort, and that reference is still there, therefore the object is still active and can be used. You would have to unbind the object so that there are no references to it anywhere in order to make sure that you destroy that object and it is no longer available. Mark
Sorry, but I have my architect hat on here. If you need a database connection, I think your current route is the bad way to go. I would think you would won't some Connection pool sitting on the server waiting to give connections out when they are needed only. Not all the time. Meaning when you web application needs to do something to the database, then it gets the Connection object from the pool, uses it and then sends it back to the pool. Using a J2EE server, you have DataSources, and Connection Pools built into the server, so that you don't have to do much work to use it. But I have been wrong before. Mark