List:Commits« Previous MessageNext Message »
From:mmatthews Date:October 23 2007 6:17pm
Subject:Connector/J commit: r6642 - in branches/branch_5_1: . src/com/mysql/jdbc/integration/jboss
View as plain text  
Modified:
   branches/branch_5_1/CHANGES
  
branches/branch_5_1/src/com/mysql/jdbc/integration/jboss/MysqlValidConnectionChecker.java
Log:
Fixed BUG#31790 MysqlValidConnectionChecker  doesn't properly handle
ReplicationConnection.

Modified: branches/branch_5_1/CHANGES
===================================================================
--- branches/branch_5_1/CHANGES	2007-10-18 00:01:46 UTC (rev 6641)
+++ branches/branch_5_1/CHANGES	2007-10-23 16:17:14 UTC (rev 6642)
@@ -4,6 +4,9 @@
 
     - JDBC-4.0-ized XAConnections and datasources.
     
+    - Fixed BUG#31790 MysqlValidConnectionChecker 
+      doesn't properly handle ReplicationConnection
+    
 10-09-07 - Version 5.1.5
 
     - Released instead of 5.1.4 to pickup patch for BUG#31053

Modified:
branches/branch_5_1/src/com/mysql/jdbc/integration/jboss/MysqlValidConnectionChecker.java
===================================================================
---
branches/branch_5_1/src/com/mysql/jdbc/integration/jboss/MysqlValidConnectionChecker.java	2007-10-18
00:01:46 UTC (rev 6641)
+++
branches/branch_5_1/src/com/mysql/jdbc/integration/jboss/MysqlValidConnectionChecker.java	2007-10-23
16:17:14 UTC (rev 6642)
@@ -30,6 +30,7 @@
 
 import org.jboss.resource.adapter.jdbc.ValidConnectionChecker;
 
+import com.mysql.jdbc.PingTarget;
 import com.mysql.jdbc.SQLError;
 
 /**
@@ -74,7 +75,17 @@
 	 * @see
org.jboss.resource.adapter.jdbc.ValidConnectionChecker#isValidConnection(java.sql.Connection)
 	 */
 	public SQLException isValidConnection(Connection conn) {
-		if (conn instanceof com.mysql.jdbc.Connection) {
+		if (conn instanceof PingTarget) {
+			try {
+				((PingTarget)conn).doPing();
+			} catch (Exception ex) {
+				if (ex instanceof SQLException) {
+					return (SQLException) ex;
+				}
+
+				return SQLError.createSQLException("Ping failed: " + ex.toString());
+			}
+		} else if (conn instanceof com.mysql.jdbc.Connection) {
 			if (pingMethod != null) {
 				try {
 					this.pingMethod.invoke(conn, null);
@@ -104,14 +115,16 @@
 			}
 		}
 
-		// Punt and use 'SELECT 1'
+		// Punt and use "/* ping */ SELECT 1" which will send
+		// pings across multi-connections too in case the connection
+		// was "wrapped" by Jboss in any way...
 
 		Statement pingStatement = null;
 
 		try {
 			pingStatement = conn.createStatement();
 			
-			pingStatement.executeQuery("SELECT 1").close();
+			pingStatement.executeQuery("/* ping */ SELECT 1").close();
 
 			return null;
 		} catch (SQLException sqlEx) {

Thread
Connector/J commit: r6642 - in branches/branch_5_1: . src/com/mysql/jdbc/integration/jbossmmatthews23 Oct