private Connection tableSetup(String insertEntryQuery) throws Throwable {
  Connection connection=null;
  Statement statement=null;
  try {
    connection=getNewConnection(true);
    statement=connection.createStatement();
    statement.executeQuery("DROP TABLE IF EXISTS replica_host_status");
    statement.executeQuery("CREATE TABLE replica_host_status (SERVER_ID VARCHAR(255), SESSION_ID VARCHAR(255), " + "LAST_UPDATE_TIMESTAMP TIMESTAMP DEFAULT NOW())");
    ResultSet resultSet=statement.executeQuery("SELECT SERVER_ID, SESSION_ID, LAST_UPDATE_TIMESTAMP " + "FROM information_schema.replica_host_status " + "WHERE LAST_UPDATE_TIMESTAMP = ("+ "SELECT MAX(LAST_UPDATE_TIMESTAMP) "+ "FROM information_schema.replica_host_status)");
    while (resultSet.next()) {
      String values="";
      for (int i=1; i < 4; i++) {
        values+=(i == 1) ? "'localhost'" : ",'" + resultSet.getString(i) + "'";
      }
      statement.executeQuery("INSERT INTO replica_host_status (SERVER_ID, SESSION_ID, LAST_UPDATE_TIMESTAMP) " + "VALUES (" + values + ")");
    }
    if (insertEntryQuery != null) {
      statement.executeQuery(insertEntryQuery);
    }
    try {
      setDbName(connection,"testj");
    }
 catch (    Throwable t) {
      fail("Unable to set database for testing");
    }
    int serverId=getServerId(connection);
    stopProxy(serverId,1);
    statement=connection.createStatement();
    statement.executeQuery("select 1");
  }
 catch (  SQLException se) {
    fail("Unable to execute queries to set up table: " + se);
  }
 finally {
    if (statement != null) {
      statement.close();
    }
  }
  return connection;
}

private Connection tableSetup ( String insertEntryQuery ) throws Throwable { Connection connection = null ; Statement statement = null ; try { connection = getNewConnection ( true ) ; statement = connection . createStatement ( ) ; statement . executeQuery ( "DROP TABLE IF EXISTS replica_host_status" ) ; statement . executeQuery ( "CREATE TABLE replica_host_status (SERVER_ID VARCHAR(255), SESSION_ID VARCHAR(255), " + "LAST_UPDATE_TIMESTAMP TIMESTAMP DEFAULT NOW())" ) ; ResultSet resultSet = statement . executeQuery ( "SELECT SERVER_ID, SESSION_ID, LAST_UPDATE_TIMESTAMP " + "FROM information_schema.replica_host_status " + "WHERE LAST_UPDATE_TIMESTAMP = (" + "SELECT MAX(LAST_UPDATE_TIMESTAMP) " + "FROM information_schema.replica_host_status)" ) ; while ( resultSet . next ( ) ) { String values = "" ; for ( int i = 1 ; i < 4 ; i ++ ) { values += ( i == 1 ) ? "'localhost'" : ",'" + resultSet . getString ( i ) + "'" ; } statement . executeQuery ( "INSERT INTO replica_host_status (SERVER_ID, SESSION_ID, LAST_UPDATE_TIMESTAMP) " + "VALUES (" + values + ")" ) ; } if ( insertEntryQuery != null ) { statement . executeQuery ( insertEntryQuery ) ; } try { setDbName ( connection , "testj" ) ; } catch ( Throwable t ) { fail ( "Unable to set database for testing" ) ; } int serverId = getServerId ( connection ) ; stopProxy ( serverId , 1 ) ; statement = connection . createStatement ( ) ; statement . executeQuery ( "select 1" ) ; } catch ( SQLException se ) { fail ( "Unable to execute queries to set up table: " + se ) ; } finally { if ( statement != null ) { statement . close ( ) ; } } return connection ; }
creates a mock replica_host_status table to imitate the database used to retrieve information about the endpoints .
