本文整理匯總了Java中com.taobao.tddl.group.jdbc.TGroupDataSource.setDbGroupKey方法的典型用法代碼示例。如果您正苦於以下問題:Java TGroupDataSource.setDbGroupKey方法的具體用法?Java TGroupDataSource.setDbGroupKey怎麽用?Java TGroupDataSource.setDbGroupKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.taobao.tddl.group.jdbc.TGroupDataSource
的用法示例。
在下文中一共展示了TGroupDataSource.setDbGroupKey方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setUp
import com.taobao.tddl.group.jdbc.TGroupDataSource; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
s1 = new TGroupDataSource();
s1.setAppName("TDDLSEQUENCE");
s1.setDbGroupKey("TDDL_SEQUENCE_GROUP0");
s1.init();
s2 = new TGroupDataSource();
s2.setAppName("TDDLSEQUENCE");
s2.setDbGroupKey("TDDL_SEQUENCE_GROUP1");
s2.init();
dao = new GroupSequenceDao();
// 設置adjust為true,這樣不必關心怎麽樣去設置有規律的值。單元化部署必須設置這個值為true,切換的時候自動更新
dao.setAdjust(true);
dao.setAppName("TDDLSEQUENCE");
List<String> dbGroups = new ArrayList<String>();
dbGroups.add("TDDL_SEQUENCE_GROUP0");
dbGroups.add("TDDL_SEQUENCE_GROUP1");
dao.setDbGroupKeys(dbGroups);
dao.setDscount(2);
dao.setInnerStep(1000);
dao.init();
updateNormalTable(0);
updateTestTable(testStart);
GroupSequence s = new GroupSequence();
s.setName("ladygaga");
s.setSequenceDao(dao);
s.init();
sequence = s;
}
示例2: TGroupDataSource
import com.taobao.tddl.group.jdbc.TGroupDataSource; //導入方法依賴的package包/類
@Test
public void 三個數據庫_測試db1可讀寫_db2與db3隻能讀_atom() throws Exception {
TGroupDataSource ds = new TGroupDataSource();
ds.setDbGroupKey(GROUP0);
ds.setAppName(APPNAME);
MockServer.setConfigInfo(ds.getFullDbGroupKey(), DSKEY0 + ":r10w" + "," + DSKEY1 + ":r20" + "," + DSKEY2
+ ":r30");
ds.init();
testCrud(ds);
}
示例3: getJT
import com.taobao.tddl.group.jdbc.TGroupDataSource; //導入方法依賴的package包/類
protected static JdbcTemplate getJT(String dbGroupKey) {
tds = new TGroupDataSource();
tds.setAppName(APPNAME);
tds.setDbGroupKey(dbGroupKey);
try {
tds.init();
} catch (TddlException e) {
Assert.fail();
}
return new JdbcTemplate(tds);
}
示例4: setUpBeforeClass
import com.taobao.tddl.group.jdbc.TGroupDataSource; //導入方法依賴的package包/類
@BeforeClass
public static void setUpBeforeClass() throws Exception {
tgds = new TGroupDataSource();
tgds.setDbGroupKey("dbKey0");
List<DataSourceWrapper> dataSourceWrappers = new ArrayList<DataSourceWrapper>();
DataSourceWrapper dsw1 = new DataSourceWrapper("db1", "rw", db1, DBType.MYSQL);
DataSourceWrapper dsw2 = new DataSourceWrapper("db2", "r", db2, DBType.MYSQL);
dataSourceWrappers.add(dsw1);
dataSourceWrappers.add(dsw2);
tgds.init(dataSourceWrappers);
}
示例5: TGroupDataSource
import com.taobao.tddl.group.jdbc.TGroupDataSource; //導入方法依賴的package包/類
@Test
public void 單個數據庫_atom() throws Exception {
TGroupDataSource ds = new TGroupDataSource();
ds.setDbGroupKey(GROUP0);
ds.setAppName(APPNAME);
MockServer.setConfigInfo(ds.getFullDbGroupKey(), DSKEY1 + ":rw");
ds.init();
testCrud(ds);
}
示例6: DataSourceWrapper
import com.taobao.tddl.group.jdbc.TGroupDataSource; //導入方法依賴的package包/類
@Test
public void 測試DataSourceWrapper() throws Exception {
List<DataSourceWrapper> dataSourceWrappers = new ArrayList<DataSourceWrapper>();
dataSourceWrappers.add(new DataSourceWrapper(DSKEY1, "rw", getMySQLDataSource(1), DBType.MYSQL));
dataSourceWrappers.add(new DataSourceWrapper(DSKEY2, "r", getMySQLDataSource(2), DBType.MYSQL));
TGroupDataSource ds = new TGroupDataSource();
ds.setDbGroupKey(GROUP0);
ds.init(dataSourceWrappers);
testCrud(ds);
}
示例7: getJT
import com.taobao.tddl.group.jdbc.TGroupDataSource; //導入方法依賴的package包/類
protected static JdbcTemplate getJT(String dbGroupKey) {
tds = new TGroupDataSource();
tds.setAppName(APPNAME);
tds.setDbGroupKey(dbGroupKey);
tds.init();
return new JdbcTemplate(tds);
}
示例8: setUp
import com.taobao.tddl.group.jdbc.TGroupDataSource; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
s1 = new TGroupDataSource();
s1.setAppName("TDDLSEQUENCE");
s1.setDbGroupKey("TDDL_SEQUENCE_GROUP0");
s1.init();
s2 = new TGroupDataSource();
s2.setAppName("TDDLSEQUENCE");
s2.setDbGroupKey("TDDL_SEQUENCE_GROUP1");
s2.init();
dao = new UnitGroupSequenceDao();
// 設置adjust為true,這樣不必關心怎麽樣去設置有規律的值。單元化部署必須設置這個值為true,切換的時候自動更新
dao.setAdjust(true);
dao.setAppName("TDDLSEQUENCE");
List<String> dbGroups = new ArrayList<String>();
dbGroups.add("TDDL_SEQUENCE_GROUP0");
dbGroups.add("TDDL_SEQUENCE_GROUP1");
dao.setDbGroupKeys(dbGroups);
dao.setDscount(2);
dao.setInnerStep(1000);
// 設定切換時候的零時表
dao.setSwitchTempTable("sequence_temp");
// 測試時先將主sequence表值設置下,具體使用時可能是應用最大的sequence id
this.updateNormalTable(0);
testUnits = new HashSet<String>();
testUnits.add("UNIT_CM3");
testUnits.add("UNIT_XINGYI");
testUnits.add("UNIT_DONGGUAN");
testUnits.add("UNIT_CM9");
currentUnit = "UNIT_CM9";
// 設置測試參數
RouterTestHelper.setTestData(testUnits, currentUnit, false);
dao.init();
// 有個名字叫ladygaga的sequence,自動初始化值
GroupSequence s = new GroupSequence();
s.setName("ladygaga");
s.setSequenceDao(dao);
s.init();
sequence = s;
}
示例9: setUp
import com.taobao.tddl.group.jdbc.TGroupDataSource; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
s1 = new TGroupDataSource();
s1.setAppName("TDDLSEQUENCE");
s1.setDbGroupKey("TDDL_SEQUENCE_GROUP0");
s1.init();
s2 = new TGroupDataSource();
s2.setAppName("TDDLSEQUENCE");
s2.setDbGroupKey("TDDL_SEQUENCE_GROUP1");
s2.init();
dao = new UnitGroupSequenceDao();
// 設置adjust為true,這樣不必關心怎麽樣去設置有規律的值。單元化部署必須設置這個值為true,切換的時候自動更新
dao.setAdjust(true);
dao.setAppName("TDDLSEQUENCE");
List<String> dbGroups = new ArrayList<String>();
dbGroups.add("TDDL_SEQUENCE_GROUP0");
dbGroups.add("TDDL_SEQUENCE_GROUP1");
dao.setDbGroupKeys(dbGroups);
dao.setDscount(2);
dao.setInnerStep(1000);
// 設定切換時候的零時表
dao.setSwitchTempTable("sequence_temp");
// 測試時先將主sequence表值設置下,具體使用時可能是應用最大的sequence id
this.updateNormalTable(0);
this.updateTestTable(testStart);
testUnits = new HashSet<String>();
testUnits.add("UNIT_CM3");
testUnits.add("UNIT_XINGYI");
testUnits.add("UNIT_DONGGUAN");
testUnits.add("UNIT_CM9");
currentUnit = "UNIT_CM9";
// 設置測試參數
RouterTestHelper.setTestData(testUnits, currentUnit, false);
dao.init();
// 有個名字叫ladygaga的sequence,自動初始化值
GroupSequence s = new GroupSequence();
s.setName("ladygaga");
s.setSequenceDao(dao);
s.init();
sequence = s;
}
示例10: main
import com.taobao.tddl.group.jdbc.TGroupDataSource; //導入方法依賴的package包/類
public static void main(String[] args) throws TddlException, SQLException {
TGroupDataSource ds = new TGroupDataSource();
ds.setDbGroupKey("CBU_WORKOPERATIONS1_TEST_GROUP");
ds.setAppName("CBU_WORKOPERATIONS_TEST_APP");
// ds.setRuleFile("rule.xml");
//
// Map cp = new HashMap();
// cp.put("ALLOW_TEMPORARY_TABLE", "True");
// cp.put(ConnectionProperties.TEMP_TABLE_DIR, ".\\temp\\");
// cp.put(ConnectionProperties.TEMP_TABLE_CUT_ROWS, false);
// cp.put(ConnectionProperties.TEMP_TABLE_MAX_ROWS, 100);
// ds.setConnectionProperties(cp);
ds.init();
System.out.println("init done");
long start = System.currentTimeMillis();
Connection conn = ds.getConnection();
PreparedStatement ps = conn.prepareStatement("SELECT a.custId, a.id,b.adgroupid, SUM(c.cost) / SUM(c.click) AS ppc,c.thedate, c.memberid, c.campaignid, c.productlineid, c.adgroupid, SUM(c.impression), SUM(c.cost), SUM(c.click), SUM(c.click) / SUM(c.impression) AS ctr, b.title, a.onlinestate, a.reason FROM Lunaadgroup a join lunaadgroupinfo b on a.id=b.adgroupid LEFT JOIN rpt_solar_adgroup_ob c ON a.id = c.adgroupid where a.custid='1102000884' and b.custid='1102000884' GROUP BY c.thedate, c.memberid, c.campaignid, c.productlineid, c.adgroupid HAVING ppc > 1 ORDER BY ppc DESC");
ResultSet rs = ps.executeQuery();
while (rs.next()) {
StringBuilder sb = new StringBuilder();
int count = rs.getMetaData().getColumnCount();
for (int i = 1; i <= count; i++) {
String key = rs.getMetaData().getColumnLabel(i);
Object val = rs.getObject(i);
sb.append("[" + rs.getMetaData().getTableName(i) + "." + key + "->" + val + "]");
}
System.out.println(sb.toString());
}
rs.close();
ps.close();
conn.close();
System.out.println("done " + (System.currentTimeMillis() - start));
}
示例11: main
import com.taobao.tddl.group.jdbc.TGroupDataSource; //導入方法依賴的package包/類
public static void main(String[] args) throws TddlException, SQLException {
TGroupDataSource ds = new TGroupDataSource();
// init a datasource with dynamic config on diamond
ds.setAppName("wap");
ds.setDbGroupKey("wap_group");
ds.init();
System.out.println("init done");
Connection conn = ds.getConnection();
// insert a record
// conn.prepareStatement("replace into sample_table (id,name,address) values (1,'sun','hz')").executeUpdate();
// System.out.println("insert done");
// select all records
PreparedStatement ps = conn.prepareStatement("/*+TDDL({\"type\":\"direct\",\"realtabs\":[traa],\"dbid\":\"tddl5_sample_group\",\"vtab\":\"sample_table\"})*/ SELECT * from sample_table");
ResultSet rs = ps.executeQuery();
while (rs.next()) {
StringBuilder sb = new StringBuilder();
int count = rs.getMetaData().getColumnCount();
for (int i = 1; i <= count; i++) {
String key = rs.getMetaData().getColumnLabel(i);
Object val = rs.getObject(i);
sb.append("[" + rs.getMetaData().getTableName(i) + "." + key + "->" + val + "]");
}
System.out.println(sb.toString());
}
rs.close();
ps.close();
conn.close();
System.out.println("query done");
}