From 71549aab6fa7e6b31d8e2831c5c6dacc8e25a979 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Wed, 8 Nov 2006 19:51:45 +0000 Subject: [PATCH] We've got to notify the connection provider that the connection went sour so that it disposes of it. --- .../jdbc/depot/PersistenceContext.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/java/com/samskivert/jdbc/depot/PersistenceContext.java b/src/java/com/samskivert/jdbc/depot/PersistenceContext.java index f1c5d10..3bb26f8 100644 --- a/src/java/com/samskivert/jdbc/depot/PersistenceContext.java +++ b/src/java/com/samskivert/jdbc/depot/PersistenceContext.java @@ -28,9 +28,13 @@ import java.sql.Connection; import java.sql.SQLException; import com.samskivert.io.PersistenceException; + +import com.samskivert.util.StringUtil; + import com.samskivert.jdbc.ConnectionProvider; import com.samskivert.jdbc.DuplicateKeyException; + /** * Defines a scope in which global annotations are shared. */ @@ -126,7 +130,6 @@ public class PersistenceContext } } catch (SQLException sqe) { - if (!isReadOnlyQuery) { // convert this exception to a DuplicateKeyException if // appropriate @@ -136,9 +139,18 @@ public class PersistenceContext } } + // let the provider know that the connection failed + _conprov.connectionFailed(_ident, isReadOnlyQuery, conn, sqe); + conn = null; + if (retryOnTransientFailure && isTransientException(sqe)) { + // the MySQL JDBC driver has the annoying habit of including + // the embedded exception stack trace in the message of their + // outer exception; if I want a fucking stack trace, I'll call + // printStackTrace() thanksverymuch + String msg = StringUtil.split(String.valueOf(sqe), "\n")[0]; Log.info("Transient failure executing operation, " + - "retrying [error=" + sqe + "]."); + "retrying [error=" + msg + "]."); } else { String msg = isReadOnlyQuery ? "Query failure " + query