Examples of TGroupDataSource


Examples of com.taobao.tddl.jdbc.group.TGroupDataSource

  public void ����DataSourceWrapper() throws Exception {
    List<DataSourceWrapper> dataSourceWrappers = new ArrayList<DataSourceWrapper>();
    dataSourceWrappers.add(new DataSourceWrapper("dbKey1","rw", DataSourceFactory.getMySQLDataSource(1), DBType.MYSQL));
    dataSourceWrappers.add(new DataSourceWrapper("dbKey2","r", DataSourceFactory.getMySQLDataSource(2), DBType.MYSQL));

    TGroupDataSource ds = new TGroupDataSource();
    ds.setDbGroupKey("myDbGroupKey");
    ds.init(dataSourceWrappers);

    Connection conn = ds.getConnection();

    //����Statement��crud
    Statement stmt = conn.createStatement();
    assertEquals(stmt.executeUpdate("insert into crud(f1,f2) values(10,'str')"), 1);
    assertEquals(stmt.executeUpdate("update crud set f2='str2'"), 1);
View Full Code Here

Examples of com.taobao.tddl.jdbc.group.TGroupDataSource

    mds.setDbIndex("");
    return mds;
  }

  private static TGroupDataSource createGroupDataSource(String weightStr) {
    TGroupDataSource tgds = new TGroupDataSource();
    tgds.setDsKeyAndWeightCommaArray(weightStr);
    tgds.setDbType(DBType.MYSQL);
    tgds.setDataSourceFetcher(new DataSourceFetcher() {
      @Override
      public DataSource getDataSource(String key) {
        return createMockDataSource(key);
      }

      @Override
      public DBType getDataSourceDBType(String key) {
        return null;
      }
    });
    tgds.init();
    return tgds;
  }
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.