Package com.mysql.jdbc

Examples of com.mysql.jdbc.ReplicationConnection.createStatement()


            .getConnectionCountWithHostAsSlave(replicationGroup1,
                secondHost));
   
    ReplicationConnectionGroupManager.removeMasterHost(replicationGroup1, firstHost);

    conn2.createStatement().execute("SELECT 1");
    assertFalse(conn2.isClosed());

    conn2.commit();

    // validate that queries are successful:
View Full Code Here


    assertFalse(conn2.isClosed());

    conn2.commit();

    // validate that queries are successful:
    conn2.createStatement().execute("SELECT 1");
    assertTrue(conn2.isHostMaster(secondHost));

    // master is now offline
    UnreliableSocketFactory.downHost("second");
    try {
View Full Code Here

    assertTrue(conn2.isHostMaster(secondHost));

    // master is now offline
    UnreliableSocketFactory.downHost("second");
    try {
      Statement lstmt = conn2.createStatement();
      lstmt.execute("SELECT 1");
      fail("Should fail here due to closed connection");
    } catch (SQLException sqlEx) {
      assertEquals("08S01", sqlEx.getSQLState());
    }
View Full Code Here

    assertFalse(conn2.isHostSlave(secondHost));
    assertTrue(conn2.isHostMaster(secondHost));
    assertTrue(conn2.isHostSlave(thirdHost));
    assertFalse(conn2.isHostMaster(thirdHost));

    conn2.createStatement().execute("SELECT 1");
    assertFalse(conn2.isClosed());

    // check that we're waiting until transaction
    // boundary to fail over.
//    assertTrue(conn2.hasPendingNewMaster());
View Full Code Here

    assertFalse(conn2.isClosed());
    assertTrue(conn2.isMasterConnection());
    assertFalse(conn2.isClosed());

    // validate that queries are successful:
    conn2.createStatement().execute("SELECT 1");
    assertTrue(conn2.isHostMaster(secondHost));

    // master is now offline
    UnreliableSocketFactory.downHost("second");
    try {
View Full Code Here

    assertTrue(conn2.isHostMaster(secondHost));

    // master is now offline
    UnreliableSocketFactory.downHost("second");
    try {
      Statement lstmt = conn2.createStatement();
      lstmt.execute("SELECT 1");
      fail("Should fail here due to closed connection");
    } catch (SQLException sqlEx) {
      assertEquals("08S01", sqlEx.getSQLState());
    }
View Full Code Here

    UnreliableSocketFactory.dontDownHost("second");
    try {
      // won't work now even though master is back up
      // connection has already been implicitly closed
      // when a new master host cannot be found:
      conn2.createStatement().execute("SELECT 1");
      fail("Will fail because inability to find new master host implicitly closes connection.");
    } catch (SQLException e) {
      assertEquals("08003", e.getSQLState());
    }
View Full Code Here

        .getUnreliableReplicationConnection(new String[] { "first",
            "second", "third" }, props, downedHosts);
    assertTrue(conn2.isReadOnly());
    assertFalse(conn2.isMasterConnection());
    try {
      conn2.createStatement().execute("SELECT 1");
    } catch (SQLException e) {
      fail("Should not fail to execute SELECT statements!");
    }
    UnreliableSocketFactory.flushAllHostLists();
    conn2.setReadOnly(false);
View Full Code Here

    UnreliableSocketFactory.flushAllHostLists();
    conn2.setReadOnly(false);
    assertFalse(conn2.isReadOnly());
    assertTrue(conn2.isMasterConnection());
    try {
      conn2.createStatement().execute("DROP TABLE IF EXISTS testRepTable");
      conn2.createStatement().execute("CREATE TABLE testRepTable (a INT)");
      conn2.createStatement().execute("INSERT INTO testRepTable VALUES (1)");
      conn2.createStatement().execute("DROP TABLE IF EXISTS testRepTable");
     
    } catch (SQLException e) {
View Full Code Here

    conn2.setReadOnly(false);
    assertFalse(conn2.isReadOnly());
    assertTrue(conn2.isMasterConnection());
    try {
      conn2.createStatement().execute("DROP TABLE IF EXISTS testRepTable");
      conn2.createStatement().execute("CREATE TABLE testRepTable (a INT)");
      conn2.createStatement().execute("INSERT INTO testRepTable VALUES (1)");
      conn2.createStatement().execute("DROP TABLE IF EXISTS testRepTable");
     
    } catch (SQLException e) {
      fail("Should not fail to execute CREATE/INSERT/DROP statements.");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.