You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Vijay K Anand <vi...@freescale.com> on 2005/07/25 13:29:31 UTC

DB Connection

hi

How to share the saem db connection across user requests..without 
exhausitn the connection pool.

regards
Vijay

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: DB Connection

Posted by Laurie Harper <la...@holoweb.net>.
Stéphane Zuckerman wrote:
> Senthilrajan VS a écrit :
>> Thanks for your response. Can u please tell me how can I close the
>> connection if the user close the window directly because I am not 
>> maintain
>> any session in the window
> 
> These are two unrelated events : you want a client-side event to create 
> a server-side event. I don't know enough JavaScript to help you an 
> "onClose" event (I don't even know if that exists). You'd better use a 
> link to make the session close, and if you really don't want to have a 
> session to stay opened too long, just shrink its timeout to a few 
> seconds. :-)

You may not be able easily to trigger a server-side session expiry event on 
window close, but the session will still expire and that *does* generate a 
server-side event.

Set up a session listener in web.xml and have your listener do the session 
clean-up, including any DB connections you have stored in your session.

Note: personally, I'd avoid associating a DB connection with each session 
like this, since it will limit how far the application can scale. The 
number of users it can support will be limited by the number of database 
connections you can cope with. Connection pools are designed to allow 
connections to be reused by different requests/sessions/users inexpensively 
precisely to avoid this kind of problem.

L.
-- 
Laurie, Open Source advocate, Java geek and novice blogger:
http://www.holoweb.net/laurie


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: DB Connection

Posted by Stéphane Zuckerman <st...@gmail.com>.
Senthilrajan VS a écrit :
> Hi Stéphane Zuckerman,
> 
> Thanks for your response. Can u please tell me how can I close the
> connection if the user close the window directly because I am not maintain
> any session in the window
> 

These are two unrelated events : you want a client-side event to create 
a server-side event. I don't know enough JavaScript to help you an 
"onClose" event (I don't even know if that exists). You'd better use a 
link to make the session close, and if you really don't want to have a 
session to stay opened too long, just shrink its timeout to a few 
seconds. :-)
-- 
Stéphane Zuckerman

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: DB Connection

Posted by Senthilrajan VS <rs...@freescale.com>.
Hi Stéphane Zuckerman,

Thanks for your response. Can u please tell me how can I close the
connection if the user close the window directly because I am not maintain
any session in the window


----- Original Message ----- 
From: "Stéphane Zuckerman" <st...@gmail.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Monday, July 25, 2005 5:34 PM
Subject: Re: DB Connection


Vijay K Anand a écrit :
> hi
>
> How to share the saem db connection across user requests..without
> exhausitn the connection pool.
>
> regards
> Vijay

You could create a plugin that connects to the Database when launching
the webapp, then put the handler in the servlet context. Then you could
retrieve it from there, or try to put it in the session scope at the
beginning of the user's session.

-- 
Stéphane Zuckerman

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: DB Connection

Posted by Stéphane Zuckerman <st...@gmail.com>.
Vijay K Anand a écrit :
> hi
> 
> How to share the saem db connection across user requests..without 
> exhausitn the connection pool.
> 
> regards
> Vijay

You could create a plugin that connects to the Database when launching 
the webapp, then put the handler in the servlet context. Then you could 
retrieve it from there, or try to put it in the session scope at the 
beginning of the user's session.

-- 
Stéphane Zuckerman

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org