本文整理汇总了Java中com.mysql.jdbc.ReplicationConnection类的典型用法代码示例。如果您正苦于以下问题:Java ReplicationConnection类的具体用法?Java ReplicationConnection怎么用?Java ReplicationConnection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ReplicationConnection类属于com.mysql.jdbc包,在下文中一共展示了ReplicationConnection类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBug12218
import com.mysql.jdbc.ReplicationConnection; //导入依赖的package包/类
/**
* Tests fix for BUG#12218, properties shared between master and slave with
* replication connection.
*
* @throws Exception
* if the test fails.
*/
public void testBug12218() throws Exception {
if (runMultiHostTests()) {
Connection replConn = null;
try {
replConn = getMasterSlaveReplicationConnection();
assertTrue(!((MySQLConnection) ((ReplicationConnection) replConn).getMasterConnection())
.hasSameProperties(((ReplicationConnection) replConn).getSlavesConnection()));
} finally {
if (replConn != null) {
replConn.close();
}
}
}
}
示例2: testReplicationConnectWithMultipleMasters
import com.mysql.jdbc.ReplicationConnection; //导入依赖的package包/类
public void testReplicationConnectWithMultipleMasters() throws Exception {
Properties props = new Properties();
props.setProperty("retriesAllDown", "3");
Set<MockConnectionConfiguration> configs = new HashSet<MockConnectionConfiguration>();
MockConnectionConfiguration first = new MockConnectionConfiguration("first", "slave", null, false);
MockConnectionConfiguration second = new MockConnectionConfiguration("second", "master", null, false);
MockConnectionConfiguration third = new MockConnectionConfiguration("third", "master", null, false);
configs.add(first);
configs.add(second);
configs.add(third);
ReplicationConnection conn2 = this.getUnreliableReplicationConnection(configs, props);
assertFalse(conn2.isReadOnly());
assertTrue(conn2.isMasterConnection());
assertTrue(conn2.isHostSlave(first.getAddress()));
assertTrue(conn2.isHostMaster(second.getAddress()));
assertTrue(conn2.isHostMaster(third.getAddress()));
}
示例3: testReplicationConnectionNoSlavesRemainOnMaster
import com.mysql.jdbc.ReplicationConnection; //导入依赖的package包/类
/**
* Test that we remain on the master when:
* - the connection is not in read-only mode
* - no slaves are configured
* - a new slave is added
*/
public void testReplicationConnectionNoSlavesRemainOnMaster() throws Exception {
Properties props = getPropertiesFromTestsuiteUrl();
String masterHost = props.getProperty(NonRegisteringDriver.HOST_PROPERTY_KEY) + ":" + props.getProperty(NonRegisteringDriver.PORT_PROPERTY_KEY);
ReplicationConnection replConn = getTestReplicationConnectionNoSlaves(masterHost);
Statement s = replConn.createStatement();
ResultSet rs1 = s.executeQuery("select CONNECTION_ID()");
assertTrue(rs1.next());
int masterConnectionId = rs1.getInt(1);
rs1.close();
s.close();
// add a slave and make sure we are NOT on a new connection
replConn.addSlaveHost(masterHost);
s = replConn.createStatement();
rs1 = s.executeQuery("select CONNECTION_ID()");
assertTrue(rs1.next());
assertEquals(masterConnectionId, rs1.getInt(1));
assertFalse(replConn.isReadOnly());
rs1.close();
s.close();
}
示例4: testBug78961
import com.mysql.jdbc.ReplicationConnection; //导入依赖的package包/类
/**
* Tests fix for Bug#78961 - Can't call MySQL procedure with InOut parameters in Fabric environment.
*
* Although this is a Fabric related bug we are able reproduce it using a couple of multi-host connections.
*/
public void testBug78961() throws Exception {
createProcedure("testBug78961", "(IN c1 FLOAT, IN c2 FLOAT, OUT h FLOAT, INOUT t FLOAT) BEGIN SET h = SQRT(c1 * c1 + c2 * c2); SET t = t + h; END;");
Connection highLevelConn = getLoadBalancedConnection(null);
assertTrue(highLevelConn.getClass().getName().startsWith("com.sun.proxy") || highLevelConn.getClass().getName().startsWith("$Proxy"));
Connection lowLevelConn = getMasterSlaveReplicationConnection(null);
// This simulates the behavior from Fabric connections that are causing the problem.
((ReplicationConnection) lowLevelConn).setProxy((MySQLConnection) highLevelConn);
CallableStatement cstmt = lowLevelConn.prepareCall("{CALL testBug78961 (?, ?, ?, ?)}");
cstmt.setFloat(1, 3.0f);
cstmt.setFloat(2, 4.0f);
cstmt.setFloat(4, 5.0f);
cstmt.registerOutParameter(3, Types.FLOAT);
cstmt.registerOutParameter(4, Types.FLOAT);
cstmt.execute();
assertEquals(5.0f, cstmt.getFloat(3));
assertEquals(10.0f, cstmt.getFloat(4));
}
示例5: testBug12218
import com.mysql.jdbc.ReplicationConnection; //导入依赖的package包/类
/**
* Tests fix for BUG#12218, properties shared between master and slave with
* replication connection.
*
* @throws Exception
* if the test fails.
*/
public void testBug12218() throws Exception {
if (runMultiHostTests()) {
Connection replConn = null;
try {
replConn = getMasterSlaveReplicationConnection();
assertTrue(!((MySQLConnection) ((ReplicationConnection) replConn).getMasterConnection()).hasSameProperties(((ReplicationConnection) replConn)
.getSlavesConnection()));
} finally {
if (replConn != null) {
replConn.close();
}
}
}
}
示例6: testBug12218
import com.mysql.jdbc.ReplicationConnection; //导入依赖的package包/类
/**
* Tests fix for BUG#12218, properties shared between master and slave with
* replication connection.
*
* @throws Exception
* if the test fails.
*/
public void testBug12218() throws Exception {
if (runMultiHostTests()) {
Connection replConn = null;
try {
replConn = getMasterSlaveReplicationConnection();
assertTrue(!((MySQLConnection) ((ReplicationConnection) replConn)
.getMasterConnection())
.hasSameProperties(((ReplicationConnection) replConn)
.getSlavesConnection()));
} finally {
if (replConn != null) {
replConn.close();
}
}
}
}
示例7: testReplicationConnectWithMultipleMasters
import com.mysql.jdbc.ReplicationConnection; //导入依赖的package包/类
public void testReplicationConnectWithMultipleMasters() throws Exception {
Properties props = new Properties();
props.setProperty("retriesAllDown", "3");
Set<MockConnectionConfiguration> configs = new HashSet<MockConnectionConfiguration>();
MockConnectionConfiguration first = new MockConnectionConfiguration("first", "slave", null, false);
MockConnectionConfiguration second = new MockConnectionConfiguration("second", "master", null, false);
MockConnectionConfiguration third = new MockConnectionConfiguration("third", "master", null, false);
configs.add(first);
configs.add(second);
configs.add(third);
ReplicationConnection conn2 = this
.getUnreliableReplicationConnection(configs, props);
assertFalse(conn2.isReadOnly());
assertTrue(conn2.isMasterConnection());
assertTrue(conn2.isHostSlave(first.getAddress()));
assertTrue(conn2.isHostMaster(second.getAddress()));
assertTrue(conn2.isHostMaster(third.getAddress()));
}
示例8: testReplicationConnectionNoSlavesRemainOnMaster
import com.mysql.jdbc.ReplicationConnection; //导入依赖的package包/类
/**
* Test that we remain on the master when:
* - the connection is not in read-only mode
* - no slaves are configured
* - a new slave is added
*/
public void testReplicationConnectionNoSlavesRemainOnMaster() throws Exception {
Properties props = getPropertiesFromTestsuiteUrl();
String masterHost = props.getProperty(NonRegisteringDriver.HOST_PROPERTY_KEY) + ":" +
props.getProperty(NonRegisteringDriver.PORT_PROPERTY_KEY);
ReplicationConnection replConn = getTestReplicationConnectionNoSlaves(masterHost);
Statement s = replConn.createStatement();
ResultSet rs1 = s.executeQuery("select CONNECTION_ID()");
assertTrue(rs1.next());
int masterConnectionId = rs1.getInt(1);
rs1.close();
s.close();
// add a slave and make sure we are NOT on a new connection
replConn.addSlaveHost(masterHost);
s = replConn.createStatement();
rs1 = s.executeQuery("select CONNECTION_ID()");
assertTrue(rs1.next());
assertEquals(masterConnectionId, rs1.getInt(1));
assertFalse(replConn.isReadOnly());
rs1.close();
s.close();
}