You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by jo...@apache.org on 2001/03/05 21:59:28 UTC
cvs commit: jakarta-turbine/src/java/org/apache/turbine/util/db/pool DBConnection.java
jon 01/03/05 12:59:27
Modified: src/java/org/apache/turbine/util/db/pool DBConnection.java
Log:
fixed the infamous java.sql.SQLException: Connection is closed! exception
the problem is that calling getConnection() within the close() was a
bad idea because it would throw an exception. in this case, we didn't
want that to happen. just reference the Connection object directly.
-jon
Revision Changes Path
1.15 +7 -4 jakarta-turbine/src/java/org/apache/turbine/util/db/pool/DBConnection.java
Index: DBConnection.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/util/db/pool/DBConnection.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- DBConnection.java 2001/02/05 03:03:34 1.14
+++ DBConnection.java 2001/03/05 20:59:27 1.15
@@ -78,7 +78,7 @@
* @author <a href="mailto:dlr@collab.net">Daniel L. Rall</a>
* @author <a href="mailto:magnus@handtolvur.is">Magn�s ��r Torfason</a>
* @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
- * @version $Id: DBConnection.java,v 1.14 2001/02/05 03:03:34 dlr Exp $
+ * @version $Id: DBConnection.java,v 1.15 2001/03/05 20:59:27 jon Exp $
*/
public class DBConnection implements PooledConnection
{
@@ -407,12 +407,15 @@
public void close()
throws SQLException
{
- Connection conn = getConnection();
+ // do not use getConnection() here because if the
+ // connection is already closed, then it will
+ // throw an exception which is not what we want
+ // here.
try
{
- if ( conn != null && !conn.isClosed() )
+ if ( connection != null && !connection.isClosed() )
{
- conn.close();
+ connection.close();
}
}
catch (Exception e)
Re: cvs commit: jakarta-turbine/src/java/org/apache/turbine/util/db/pool DBConnection.java
Posted by Daniel Rall <dl...@collab.net>.
Jon Stevens <jo...@latchkey.com> writes:
> on 3/5/01 2:17 PM, "Daniel Rall" <dl...@collab.net> wrote:
>
> > Nice work, Jon. Bug squashed.
> >
> > p.s. Should we still send replies to the dev@ list now that Turbine
> > has its own cvs@ list?
>
> dev@ and cvs@ are same thing. that is why commit messages are showing up on
> dev@ now. :-)
Ah, okay...jakarta-turbine-cvs@apache.org is just an alias to
turbine-dev@jakarta.apache.org, then. Gotcha.
> we can opt to split the two lists up, but i would rather have anyone on the
> dev@ list also be concerned with all commits. especially now that we also
> have a user@ list as well.
I much prefer it as is.
--
Daniel Rall <dl...@collab.net>
Re: cvs commit:
jakarta-turbine/src/java/org/apache/turbine/util/db/pool DBConnection.java
Posted by Jon Stevens <jo...@latchkey.com>.
on 3/5/01 2:17 PM, "Daniel Rall" <dl...@collab.net> wrote:
> Nice work, Jon. Bug squashed.
>
> p.s. Should we still send replies to the dev@ list now that Turbine
> has its own cvs@ list?
dev@ and cvs@ are same thing. that is why commit messages are showing up on
dev@ now. :-)
we can opt to split the two lists up, but i would rather have anyone on the
dev@ list also be concerned with all commits. especially now that we also
have a user@ list as well.
thanks,
-jon
--
If you come from a Perl or PHP background, JSP is a way to take
your pain to new levels. --Anonymous
<http://jakarta.apache.org/velocity/ymtd/ymtd.html>
Re: cvs commit: jakarta-turbine/src/java/org/apache/turbine/util/db/pool DBConnection.java
Posted by Daniel Rall <dl...@collab.net>.
Nice work, Jon. Bug squashed.
p.s. Should we still send replies to the dev@ list now that Turbine
has its own cvs@ list?
jon@apache.org writes:
> jon 01/03/05 12:59:27
>
> Modified: src/java/org/apache/turbine/util/db/pool DBConnection.java
> Log:
> fixed the infamous java.sql.SQLException: Connection is closed! exception
>
> the problem is that calling getConnection() within the close() was a
> bad idea because it would throw an exception. in this case, we didn't
> want that to happen. just reference the Connection object directly.
>
> -jon
>
> Revision Changes Path
> 1.15 +7 -4 jakarta-turbine/src/java/org/apache/turbine/util/db/pool/DBConnection.java
>
> Index: DBConnection.java
> ===================================================================
> RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/util/db/pool/DBConnection.java,v
> retrieving revision 1.14
> retrieving revision 1.15
> diff -u -r1.14 -r1.15
> --- DBConnection.java 2001/02/05 03:03:34 1.14
> +++ DBConnection.java 2001/03/05 20:59:27 1.15
> @@ -78,7 +78,7 @@
> * @author <a href="mailto:dlr@collab.net">Daniel L. Rall</a>
> * @author <a href="mailto:magnus@handtolvur.is">Magnús Þór Torfason</a>
> * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
> - * @version $Id: DBConnection.java,v 1.14 2001/02/05 03:03:34 dlr Exp $
> + * @version $Id: DBConnection.java,v 1.15 2001/03/05 20:59:27 jon Exp $
> */
> public class DBConnection implements PooledConnection
> {
> @@ -407,12 +407,15 @@
> public void close()
> throws SQLException
> {
> - Connection conn = getConnection();
> + // do not use getConnection() here because if the
> + // connection is already closed, then it will
> + // throw an exception which is not what we want
> + // here.
> try
> {
> - if ( conn != null && !conn.isClosed() )
> + if ( connection != null && !connection.isClosed() )
> {
> - conn.close();
> + connection.close();
> }
> }
> catch (Exception e)
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
>
--
Daniel Rall <dl...@collab.net>