db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Armin Waibel <arm...@apache.org>
Subject Re: [PATCH] Replace closed connection in ConnectionManagerImpl
Date Thu, 15 Apr 2004 14:02:09 GMT
Hi,

Lorenz Froihofer wrote:
> Hi,
> 
>  >>
>  >> It allows to replace closed connections if there is no transaction
>  >> running. Without this patch closed connections are never replaced in
>  >> ConnectionManagerImpl.
>  >>
>  >
>  >hmm, why do we need this? How can the ConnectionManager hold a closed
>  >connection? OJB classes itself never close a connection, expect in
>  >ConnectionFactory impl classes.
>  >Can you explain why you/we need this.
> 
> I use OJB with a standalone application. The ConnectionManagerImpl never 
> releases the connection.

I assume you never close the used PB instance after use. The used 
connection was "closed" (means returned to ConnectionFactory 
implementation) on PB.commitTransaction/rollbackTransaction/close. So if 
you do a read-only operation and do not close the used PB instance than 
the connection was NOT released.
If you don't want to close the used PB instance, you can use 
PB.serviceConnectionManager#releaseConnection to "close" the connection. 
But I recommend to close the PB instance after use (PB instances are 
pooled too, so this shouldn't be a performance issue).

> If I restart the MySQL database server but keep 
> the application running, the existing connection is unusable thereafter. 

This should be handled by the ConnectionFactory implementation. If you 
want do additional checks extend one of the ConnectionFactory 
implemetnations.

> The only option is to restart the application, which is not what I want.
> 
> So I thought it might be a good idea to provide a mechanism to detect 
> closed (or unusable) connections.

As said above this should be done in ConnectionFactory implementation.

regards,
Armin

> This allows to keep applications 
> running even if the database server is restartet. Sometimes database 
> connections are simply lost without even restarting the database server 
> -- yes, this happens.
> 
> Kind regards,
>   Lorenz.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message