Bug #34937 MysqlConnectionPoolDataSource does not support ReplicationConnection
Submitted: 28 Feb 2008 18:16 Modified: 7 Jul 2008 13:22
Reporter: Domas Mituzas Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.1 OS:Any
Assigned to: CPU Architecture:Any
Tags: pool, pooling, replication

[28 Feb 2008 18:16] Domas Mituzas
Description:
ReplicationConnection cannot be used in MysqlConnectionPoolDataSource - cast fails

How to repeat:
import java.util.*;
import java.sql.*;
import javax.sql.*;

public class pooledrep {
	public static void main(String[] args) {
		PooledConnection conn = null;
		try {
			com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource ds = new com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource();
			ds.setURL("jdbc:mysql:replication://localhost:3306,localhost:3306/test");
			conn = ds.getPooledConnection();
		} catch (Exception e) {
			System.err.println ("Error message: " + e.getMessage ());
               		e.printStackTrace();
		}
	}
}

flute:~/Tests/jdbc midom$ ./run51 pooledrep
Error message: com.mysql.jdbc.ReplicationConnection
java.lang.ClassCastException: com.mysql.jdbc.ReplicationConnection
        at com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource.getPooledConnection(MysqlConnectionPoolDataSource.java:59)
        at pooledrep.main(pooledrep.java:11)

Suggested fix:
make ReplicationConnection castable to Connection
[29 Feb 2008 3:41] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/43193
[29 Feb 2008 6:54] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/43195
[1 Mar 2008 12:28] MC Brown
A note has been added to the 5.1.6 changelog: 

MysqlConnectionPoolDataSource does not support ReplicationConnection. Notice that we implemented com.mysql.jdbc.Connection for ReplicationConnection, however, only accessors from ConnectionProperties are implemented (not the mutators), and they return values from the currently active connection. All other methods from com.mysql.jdbc.Connection are implemented, and operate on the currently active connection, with the exception of resetServerState() and changeUser().
[3 Mar 2008 12:17] Domas Mituzas
Though previous error is gone, I'm reopening this with new testcase for same issue, that still fails:

import java.util.*;
import java.sql.*;
import javax.sql.*;

public class pooledrep {
        public static void main(String[] args) {
                PooledConnection conn = null;
                try {
                        com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource ds = new com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource();
                        ds.setURL("jdbc:mysql:replication://localhost:3306,localhost:3306/test");
                        conn = ds.getPooledConnection();
                        conn.getConnection();
                } catch (Exception e) {
                        System.err.println ("Error message: " + e.getMessage ());
                        e.printStackTrace();
                }
        }
}

flute:~/Tests/jdbc midom$ ./run51 pooledrep
Error message: com.mysql.jdbc.ReplicationConnection
java.lang.ClassCastException: com.mysql.jdbc.ReplicationConnection
        at com.mysql.jdbc.jdbc2.optional.MysqlPooledConnection.getConnection(MysqlPooledConnection.java:179)
        at com.mysql.jdbc.jdbc2.optional.MysqlPooledConnection.getConnection(MysqlPooledConnection.java:153)
        at pooledrep.main(pooledrep.java:12)
[3 Mar 2008 19:16] Julian Duta
Hi, I've been going through the src and the reason why this still happens is because ConnectionImpl is used directly in a number of classes (i.e MysqlPoolableConnection). I'm guess it should not be casted directly to the implementation but rather the interface?
[3 Mar 2008 21:27] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/43341
[7 Mar 2008 20:56] Julian Duta
Seems to be working now. Thank you!
[7 Jul 2008 13:22] Tony Bedford
No further details need to be added to the existing 5.1.6 Changelog entry.
[30 Jul 2008 14:53] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/50724
[30 Jul 2008 14:53] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/50724
[30 Jul 2008 14:53] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/50724