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 07:24:04 GMT
Hi Lorenz,

Lorenz Froihofer wrote:
> Hi,
> 
> Is it possible to apply the attached patch to ConnectionManagerImpl.java
> 
> 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.

regards,
Armin

> The patch basically replaces the lines
> 
> 103: if (con == null)
> 104: {
> 105:     con = this.connectionFactory.lookupConnection(jcd);
> 
> with
> 
> 103: if ((con == null) || (!isInLocalTransaction() && con.isClosed()))
> 104: {
> 105:     if (con != null)
> 106:     {
> 107:         releaseConnection();
> 108:     }
> 109:     con = this.connectionFactory.lookupConnection(jcd);
> 
> Furthermore, a try - catch statement is wrapped around the if-statement 
> on line 103.
> 
> Kind regards,
>   Lorenz.
> 
> 
> ------------------------------------------------------------------------
> 
> --- db-ojb-1.0.rc6/src/java/org/apache/ojb/broker/accesslayer/ConnectionManagerImpl.java
2004-04-15 00:36:10.000000000 +0200
> +++ db-ojb-1.0.rc6.ori/src/java/org/apache/ojb/broker/accesslayer/ConnectionManagerImpl.java
2004-03-28 12:14:16.000000000 +0200
> @@ -84,7 +84,7 @@
>      {
>          return this.platform;
>      }
> -    
> +
>      /**
>       * Returns the underlying connection, requested at the
>       * {@link org.apache.ojb.broker.accesslayer.ConnectionFactory}.
> @@ -100,32 +100,22 @@
>          // if (con == null || !isAlive(con))
>          // isAlive check, how do we react if false and we in tx?
>          // create a new connection isn't the right way I think.
> -        try 
> +        if (con == null)
>          {
> -            if ((con == null) || (!isInLocalTransaction() && con.isClosed()))
> +            con = this.connectionFactory.lookupConnection(jcd);
> +            if (con == null) throw new PersistenceBrokerException("Cannot get connection
for " + jcd);
> +            if (jcd.getUseAutoCommit() == JdbcConnectionDescriptor.AUTO_COMMIT_SET_TRUE_AND_TEMPORARY_FALSE)
>              {
> -                if (con != null) {
> -                    releaseConnection();
> +                try
> +                {
> +                    this.originalAutoCommitState = con.getAutoCommit();
>                  }
> -                con = this.connectionFactory.lookupConnection(jcd);
> -                if (con == null) throw new PersistenceBrokerException("Cannot get connection
for " + jcd);
> -                if (jcd.getUseAutoCommit() == JdbcConnectionDescriptor.AUTO_COMMIT_SET_TRUE_AND_TEMPORARY_FALSE)
> +                catch (SQLException e)
>                  {
> -                    try
> -                    {
> -                        this.originalAutoCommitState = con.getAutoCommit();
> -                    }
> -                    catch (SQLException e)
> -                    {
> -                        throw new PersistenceBrokerException("Cannot request autoCommit
state on the connection", e);
> -                    }
> +                    throw new PersistenceBrokerException("Cannot request autoCommit
state on the connection", e);
>                  }
> -                if (log.isDebugEnabled()) log.debug("Request new connection from ConnectionFactory:
" + con);
>              }
> -        } 
> -        catch(SQLException e) 
> -        {
> -            log.error("Error when executing con.isClosed()",e);
> +            if (log.isDebugEnabled()) log.debug("Request new connection from ConnectionFactory:
" + con);
>          }
>  
>          if (isBatchMode())
> 
> 
> 
> ------------------------------------------------------------------------
> 
> ---------------------------------------------------------------------
> 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