*
* @throws Exception
*/
public void testBug16224249() throws Exception {
Properties props = new NonRegisteringDriver().parseURL(dbUrl, null);
String host = props.getProperty(NonRegisteringDriver.HOST_PROPERTY_KEY, "localhost");
String port = props.getProperty(NonRegisteringDriver.PORT_PROPERTY_KEY, "3306");
String hostSpec = host;
if (!NonRegisteringDriver.isHostPropertiesList(host)) {
hostSpec = host + ":" + port;
}
String database = props.getProperty(NonRegisteringDriver.DBNAME_PROPERTY_KEY);
removeHostRelatedProps(props);
props.remove(NonRegisteringDriver.DBNAME_PROPERTY_KEY);
StringBuilder configs = new StringBuilder();
for (@SuppressWarnings("rawtypes")
Map.Entry entry : props.entrySet()) {
configs.append(entry.getKey());
configs.append("=");
configs.append(entry.getValue());
configs.append("&");
}
String loadbalanceUrl = String.format("jdbc:mysql:loadbalance://%s,%s/%s?%s", hostSpec, hostSpec, database, configs.toString());
String failoverUrl = String.format("jdbc:mysql://%s,%s/%s?%s", hostSpec, "127.0.0.1:"+port, database, configs.toString());
Connection[] loadbalancedconnection = new Connection[] {
new NonRegisteringDriver().connect(loadbalanceUrl, null),
new NonRegisteringDriver().connect(loadbalanceUrl, null),
new NonRegisteringDriver().connect(loadbalanceUrl, null)
};
Connection[] failoverconnection = new Connection[] {
new NonRegisteringDriver().connect(failoverUrl, null),
new NonRegisteringDriver().connect(failoverUrl, null),
new NonRegisteringDriver().connect(failoverUrl, null)
};
// WebLogic-style test
Class<?> mysqlCls = null;
Class<?> jcls = failoverconnection[0].getClass(); // the driver-level connection, a Proxy in this case...