You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by starki78 <st...@libero.it> on 2006/02/14 15:17:11 UTC

Problem with Connection Pool in Action-Classes

Hi, 
we have a connection-member variable
in our super-action that is opened
and closed there by the connection-pool.
(it's always clossed within the finally block)
Now then we call the sub-classes very
often in a short period it seems
the connection isn't been given back!!!
It seems that the action is not absolutely thread safe.
Can this be?

Thanks for any answer
Starky


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


Re: Problem with Connection Pool in Action-Classes

Posted by Dave Newton <ne...@pingsite.com>.
starki78 wrote:
> It seems that the action is not absolutely thread safe.
> Can this be?
>   
Actions should never* have instance variables. You should not have a
connection stored as an instance variable; it should be retrieved within
a method to a method-local variable. If this is what you are doing I'm
surprised you haven't had more issues.

Think of an Action like a servlet: if you have instance variables and
you write to them during a method and it's not synchronized you are
probably making a mistake.

* Of course, if you deal with synchronization issues, never mind. If
it's a read-only variable it probably doesn't matter.

Dave



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