| Bug #34937 | MysqlConnectionPoolDataSource does not support ReplicationConnection | ||
|---|---|---|---|
| Submitted: | 28 Feb 19:16 | Modified: | 7 Jul 15:22 |
| Reporter: | Domas Mituzas | ||
| Status: | Closed | ||
| Category: | Connector/J | Severity: | S3 (Non-critical) |
| Version: | 5.1 | OS: | Any |
| Assigned to: | Target Version: | ||
| Tags: | pooling, pool, replication | ||
| Triage: | D3 (Medium) | ||
[29 Feb 4: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 7: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 13: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 13: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.ja
va:179)
at
com.mysql.jdbc.jdbc2.optional.MysqlPooledConnection.getConnection(MysqlPooledConnection.ja
va:153)
at pooledrep.main(pooledrep.java:12)
[3 Mar 20: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 22: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 21:56]
Julian Duta
Seems to be working now. Thank you!
[7 Jul 15:22]
Tony Bedford
No further details need to be added to the existing 5.1.6 Changelog entry.

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(MysqlConne ctionPoolDataSource.java:59) at pooledrep.main(pooledrep.java:11) Suggested fix: make ReplicationConnection castable to Connection