Package com.mysql.jdbc

Examples of com.mysql.jdbc.ReplicationDriver


    }
  }

  protected Connection getMasterSlaveReplicationConnection() throws SQLException {
 
    Connection replConn = new ReplicationDriver().connect(
        getMasterSlaveUrl(), getMasterSlaveProps());
 
    return replConn;
  }
View Full Code Here


  }
 
    private Connection getMasterSlaveReplicationConnection()
      throws SQLException {
   
    Connection replConn = new ReplicationDriver().connect(
        getMasterSlaveUrl(), getMasterSlaveProps());

    return replConn;
  }
View Full Code Here

    }
  }

  protected Connection getMasterSlaveReplicationConnection() throws SQLException {
 
    Connection replConn = new ReplicationDriver().connect(
        getMasterSlaveUrl(), getMasterSlaveProps());
 
    return replConn;
  }
View Full Code Here

    }
  }

  protected Connection getMasterSlaveReplicationConnection() throws SQLException {
 
    Connection replConn = new ReplicationDriver().connect(
        getMasterSlaveUrl(), getMasterSlaveProps());
 
    return replConn;
  }
View Full Code Here

    }
  }

  static void initConnection() throws Exception {
    String url = "jdbc:mysql://localhost,localhost:3306/test";
    ReplicationDriver driver = new ReplicationDriver();
    Properties props = new Properties();
    //props.put("propertiesTransform", "my.NotFoundConnectionPropertiesTransform");

    props.put("user", "root");
    props.put("password", "test");
    props.put("holdResultsOpenOverStatementClose", "true");
    //props.put("allowMultiQueries","true");
    props.put("useCursorFetch", "true");
    //props.put("traceProtocol","true");
    // We want this for failover on the slaves
    //props.put("autoReconnect", "true");
    // We want to load balance between the slaves
    props.put("roundRobinLoadBalance", "true");

    //会抛出NullPointerException,是个Bug???
    //props.put("retriesAllDown", "0");
    props.put("retriesAllDown", "3"); //retriesAllDown默认是120,所以主机不可用时重试次数

    props.put("loadBalanceBlacklistTimeout", "1");

    //loadBalanceStrategy默认是random,也可以自定义一个实现com.mysql.jdbc.BalanceStrategy接口的类
    props.put("loadBalanceStrategy", "bestResponseTime");

    //
    // Looks like a normal MySQL JDBC url, with a
    // comma-separated list of hosts, the first
    // being the 'master', the rest being any number
    // of slaves that the driver will load balance against
    //
    conn = driver.connect(url, props);
  }
View Full Code Here

  }

  protected Connection getMasterSlaveReplicationConnection()
      throws SQLException {

    Connection replConn = new ReplicationDriver().connect(
        getMasterSlaveUrl(), getMasterSlaveProps());

    return replConn;
  }
View Full Code Here

TOP

Related Classes of com.mysql.jdbc.ReplicationDriver

Copyright © 2018 www.massapicom. 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.