Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Databse session and web session issue

 
kent
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?

Thanks in advance.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not a beginner's question. Moving to servlets.
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Wkw Kent"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the
JavaRanch Naming Policy.
You can change it
here.
Thanks! and welcome to the JavaRanch!
Mark
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic