We've got to notify the connection provider that the connection went sour

so that it disposes of it.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@1968 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
ray
2006-11-08 19:51:45 +00:00
parent 154be182a6
commit 10b68d9092
@@ -28,9 +28,13 @@ import java.sql.Connection;
import java.sql.SQLException; import java.sql.SQLException;
import com.samskivert.io.PersistenceException; import com.samskivert.io.PersistenceException;
import com.samskivert.util.StringUtil;
import com.samskivert.jdbc.ConnectionProvider; import com.samskivert.jdbc.ConnectionProvider;
import com.samskivert.jdbc.DuplicateKeyException; import com.samskivert.jdbc.DuplicateKeyException;
/** /**
* Defines a scope in which global annotations are shared. * Defines a scope in which global annotations are shared.
*/ */
@@ -126,7 +130,6 @@ public class PersistenceContext
} }
} catch (SQLException sqe) { } catch (SQLException sqe) {
if (!isReadOnlyQuery) { if (!isReadOnlyQuery) {
// convert this exception to a DuplicateKeyException if // convert this exception to a DuplicateKeyException if
// appropriate // 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)) { 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, " + Log.info("Transient failure executing operation, " +
"retrying [error=" + sqe + "]."); "retrying [error=" + msg + "].");
} else { } else {
String msg = isReadOnlyQuery ? "Query failure " + query String msg = isReadOnlyQuery ? "Query failure " + query