use of com.ctrip.platform.dal.dao.DalHints in project dal by ctripcorp.
the class DalTabelDaoShardByTableSqlSvrTest method setUpBeforeClass.
@BeforeClass
public static void setUpBeforeClass() throws Exception {
DalClientFactory.initClientFactory();
clientSqlSvr = DalClientFactory.getClient(DATABASE_NAME_SQLSVR);
DalHints hints = new DalHints();
String[] sqls = null;
// For SQL server
hints = new DalHints();
StatementParameters parameters = new StatementParameters();
for (int i = 0; i < mod; i++) {
sqls = new String[] { String.format(DROP_TABLE_SQL_SQLSVR_TPL, i, i), String.format(CREATE_TABLE_SQL_SQLSVR_TPL, i) };
for (int j = 0; j < sqls.length; j++) {
clientSqlSvr.update(sqls[j], parameters, hints);
}
}
clientSqlSvr.update(DROP_TABLE_SQL_SQLSVR_TPL_1, parameters, hints);
}
use of com.ctrip.platform.dal.dao.DalHints in project dal by ctripcorp.
the class DalQueryDaoTest method testQueryFirstAllShards.
@Test
public void testQueryFirstAllShards() {
try {
DalHints hints = new DalHints();
ClientTestModel result = queryFirstInAllShard(hints);
assertNotNull(result);
assertEquals(1, result.id);
} catch (Exception e) {
fail();
}
}
use of com.ctrip.platform.dal.dao.DalHints in project dal by ctripcorp.
the class DalTabelDaoShardByTableMySqlTest method tearDown.
@After
public void tearDown() throws Exception {
String sql = "DELETE FROM " + TABLE_NAME;
StatementParameters parameters = new StatementParameters();
DalHints hints = new DalHints();
try {
for (int i = 0; i < mod; i++) {
clientMySql.update(sql + "_" + i, parameters, hints);
}
} catch (SQLException e) {
e.printStackTrace();
fail();
}
}
use of com.ctrip.platform.dal.dao.DalHints in project dal by ctripcorp.
the class DalTabelDaoShardByTableMySqlTest method setUpBeforeClass.
@BeforeClass
public static void setUpBeforeClass() throws Exception {
DalClientFactory.initClientFactory();
clientMySql = DalClientFactory.getClient(DATABASE_NAME_MYSQL);
DalHints hints = new DalHints();
String[] sqls = null;
for (int i = 0; i < mod; i++) {
sqls = new String[] { DROP_TABLE_SQL_MYSQL, String.format(DROP_TABLE_SQL_MYSQL_TPL, i), String.format(CREATE_TABLE_SQL_MYSQL_TPL, i) };
clientMySql.batchUpdate(sqls, hints);
}
}
use of com.ctrip.platform.dal.dao.DalHints in project dal by ctripcorp.
the class DalTableDaoShardByDbOracleTest method setUp.
@Before
public void setUp() throws Exception {
setUpBeforeClass();
DalHints hints = new DalHints();
String[] insertSqls = null;
for (int i = 0; i < mod; i++) {
insertSqls = new String[5];
insertSqls[0] = DROP_TABLE_SEQ;
insertSqls[1] = CREATE_TABLE_SEQ;
insertSqls = new String[] { "INSERT INTO " + TABLE_NAME + "(quantity,tableIndex,type,address)" + " VALUES(10, " + i + " ,1, 'SH INFO')", "INSERT INTO " + TABLE_NAME + "(quantity,tableIndex,type,address)" + " VALUES(11, " + i + " ,1, 'BJ INFO')", "INSERT INTO " + TABLE_NAME + "(quantity,tableIndex,type,address)" + " VALUES(12, " + i + " ,1, 'SZ INFO')" };
client.batchUpdate(insertSqls, hints.inShard(i));
}
}
Aggregations