cobar 之外的选择 ReplicationDriver

public  class  ReplicationDriverTest {
   public  static  void  main(String[] args) throws  Exception {
     ReplicationDriver driver = new  ReplicationDriver();
     Properties props = new  Properties();
     props.put( "autoReconnect" , "true" );
     props.put( "roundRobinLoadBalance" , "true" );
     props.put( "user" , "root" );
     props.put( "password" , "root" );  
     Connection conn= driver.connect( "jdbc:mysql:replication://master,slave1,slave2,slave3/...." ,   props);
     conn.setReadOnly( false );
     conn.setAutoCommit( false );
     conn.createStatement().executeUpdate( "update  test  .........." );
     conn.commit();  
     conn.setReadOnly( true );  
     ResultSet rs =   conn.createStatement().executeQuery("select ......." );
   }
}

你可能感兴趣的:(cobar 之外的选择 ReplicationDriver)