本文整理汇总了Java中com.mysql.jdbc.ConnectionGroupManager类的典型用法代码示例。如果您正苦于以下问题:Java ConnectionGroupManager类的具体用法?Java ConnectionGroupManager怎么用?Java ConnectionGroupManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConnectionGroupManager类属于com.mysql.jdbc包,在下文中一共展示了ConnectionGroupManager类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBug22730682
import com.mysql.jdbc.ConnectionGroupManager; //导入依赖的package包/类
/**
* Tests fix for Bug#22730682 - ARRAYINDEXOUTOFBOUNDSEXCEPTION FROM CONNECTIONGROUPMANAGER.REMOVEHOST().
*
* This bug was caused by an incorrect array handling when removing an host from a load balanced connection group, with the option to affect existing
* connections.
*/
public void testBug22730682() throws Exception {
Properties connProps = getPropertiesFromTestsuiteUrl();
String host = connProps.getProperty(NonRegisteringDriver.HOST_PROPERTY_KEY, "localhost");
String port = connProps.getProperty(NonRegisteringDriver.PORT_PROPERTY_KEY, "3306");
final String currentHost = host + ":" + port;
final String dummyHost = "bug22730682:12345";
final Properties props = new Properties();
Connection testConn;
final String lbConnGroup1 = "Bug22730682LB1";
props.setProperty("loadBalanceConnectionGroup", lbConnGroup1);
testConn = getLoadBalancedConnection(3, dummyHost, props);
assertEquals(2, ConnectionGroupManager.getActiveHostCount(lbConnGroup1));
assertTrue(ConnectionGroupManager.getActiveHostLists(lbConnGroup1).contains(dummyHost));
assertTrue(ConnectionGroupManager.getActiveHostLists(lbConnGroup1).contains(currentHost));
ConnectionGroupManager.removeHost(lbConnGroup1, dummyHost);
assertEquals(1, ConnectionGroupManager.getActiveHostCount(lbConnGroup1));
assertTrue(ConnectionGroupManager.getActiveHostLists(lbConnGroup1).contains(currentHost));
testConn.close();
final String lbConnGroup2 = "Bug22730682LB2";
props.setProperty("loadBalanceConnectionGroup", lbConnGroup2);
testConn = getLoadBalancedConnection(3, dummyHost, props);
assertEquals(2, ConnectionGroupManager.getActiveHostCount(lbConnGroup2));
assertTrue(ConnectionGroupManager.getActiveHostLists(lbConnGroup2).contains(dummyHost));
assertTrue(ConnectionGroupManager.getActiveHostLists(lbConnGroup2).contains(currentHost));
ConnectionGroupManager.removeHost(lbConnGroup2, dummyHost, true);
assertEquals(1, ConnectionGroupManager.getActiveHostCount(lbConnGroup2));
assertTrue(ConnectionGroupManager.getActiveHostLists(lbConnGroup2).contains(currentHost));
testConn.close();
}
示例2: addHost
import com.mysql.jdbc.ConnectionGroupManager; //导入依赖的package包/类
public void addHost(String group, String host, boolean forExisting) {
try {
ConnectionGroupManager.addHost(group, host, forExisting);
} catch (Exception e) {
e.printStackTrace();
}
}
示例3: addHost
import com.mysql.jdbc.ConnectionGroupManager; //导入依赖的package包/类
public void addHost(String group, String host, boolean forExisting) {
try {
ConnectionGroupManager.addHost(group, host, forExisting);
} catch (Exception e){
e.printStackTrace();
}
}
示例4: getActiveHostCount
import com.mysql.jdbc.ConnectionGroupManager; //导入依赖的package包/类
public int getActiveHostCount(String group) {
return ConnectionGroupManager.getActiveHostCount(group);
}
示例5: getActiveLogicalConnectionCount
import com.mysql.jdbc.ConnectionGroupManager; //导入依赖的package包/类
public long getActiveLogicalConnectionCount(String group) {
return ConnectionGroupManager.getActiveLogicalConnectionCount(group);
}
示例6: getActivePhysicalConnectionCount
import com.mysql.jdbc.ConnectionGroupManager; //导入依赖的package包/类
public long getActivePhysicalConnectionCount(String group) {
return ConnectionGroupManager.getActivePhysicalConnectionCount(group);
}
示例7: getActiveHostsList
import com.mysql.jdbc.ConnectionGroupManager; //导入依赖的package包/类
public String getActiveHostsList(String group) {
return ConnectionGroupManager.getActiveHostLists(group);
}
示例8: getRegisteredConnectionGroups
import com.mysql.jdbc.ConnectionGroupManager; //导入依赖的package包/类
public String getRegisteredConnectionGroups() {
return ConnectionGroupManager.getRegisteredConnectionGroups();
}