Sean Clark wrote:Holding a database Connection for this long is probably not a wise idea.
Anirvan Majumdar wrote:I don't think there's anything particularly unwise about how 'long' a database connection is held. If that was the case, connection pools would have never come to exist. What is usually unwise is how a particular 'live' connection is sustained. In any application which uses database for persistence, establishing new connections consume the greatest amount of time.
I'd suggest you look into database connection pooling as a more appropriate alternative.
you still have the same underlying question as to when do you create the connection/get connection from pool and when do you drop the connection/release to pool.
Abubacker Siddik wrote:Please demonstrate the bit of db code using filter...I still dont get it
Abubacker Siddik wrote:Well Guys, I think you have to come to my question right now.
Anirvan, I can use connection pooling using the application server. I wonder if i use ContextListener for this purpose, as long as my server is running, my connections will be there..Doesnt it seem unwise?
Ankit Garg, Ya i know there is a pattern called DAO which we could use for interacting DB calls. Sean suggested me to use filters, thats y i asked to show a demo..
Abubacker Siddik wrote:Hi all,
For opening and closing a database connection, can i use HttpSessionListener? When i open a new session, i can open db connection. but i remove the session i will close db connection.. My doubt is that will my methodology affect the other session's db connection???