本文整理匯總了Java中com.taobao.tddl.common.model.DBType類的典型用法代碼示例。如果您正苦於以下問題:Java DBType類的具體用法?Java DBType怎麽用?Java DBType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DBType類屬於com.taobao.tddl.common.model包,在下文中一共展示了DBType類的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getDataSource
import com.taobao.tddl.common.model.DBType; //導入依賴的package包/類
@Override
public DataSource getDataSource(String dsKey) {
DataSourceWrapper dsw = dataSourceWrapperMap.get(dsKey);
if (dsw != null) {
dbType = dsw.getDBType();
return dsw.getWrappedDataSource();
} else {
if (createTAtomDataSource) {
TAtomDsStandard atomDs = initAtomDataSource(tGroupDataSource.getAppName(),
dsKey,
tGroupDataSource.getUnitName());
dbType = DBType.valueOf(atomDs.getDbType().name());
return atomDs;
} else {
throw new IllegalArgumentException(dsKey + " not exist!");
}
}
}
示例2: createEquityDbManager
import com.taobao.tddl.common.model.DBType; //導入依賴的package包/類
private static EquityDbManager createEquityDbManager(List<DataSourceWrapper> list, boolean isRead,
GroupExtraConfig groupExtraConfig) {
Map<String, DataSourceWrapper> dataSourceMap = new HashMap<String, DataSourceWrapper>(list.size());
Map<String, Integer> weightMap = new HashMap<String, Integer>(list.size());
DBType dbType = null;
for (DataSourceWrapper dsw : list) {
String dsKey = dsw.getDataSourceKey();
dataSourceMap.put(dsKey, dsw);
weightMap.put(dsKey, isRead ? dsw.getWeight().r : dsw.getWeight().w);
if (dbType == null) {
dbType = dsw.getDBType();
}
}
EquityDbManager equityDbManager = new EquityDbManager(dataSourceMap, weightMap, groupExtraConfig);
equityDbManager.setDbType(dbType);
return equityDbManager;
}
示例3: genFatalSQLException
import com.taobao.tddl.common.model.DBType; //導入依賴的package包/類
public SQLException genFatalSQLException() throws SQLException {
if (DBType.MYSQL.equals(dbType)) {
return new SQLException("dsClosed", "08001");// 來自MySQLExceptionSorter
} else if (DBType.ORACLE.equals(dbType)) {
return new SQLException("dsClosed", "28");// 來自OracleExceptionSorter
// //28 session has been
// killed
} else {
throw new RuntimeException("有了新的dbType而這裏沒有更新");
}
}
示例4: DataSourceWrapper
import com.taobao.tddl.common.model.DBType; //導入依賴的package包/類
public DataSourceWrapper(String dataSourceKey, String weightStr, DataSource wrappedDataSource, DBType dbType,
int dataSourceIndex){
this.dataSourceKey = dataSourceKey;
this.weight = new Weight(weightStr);
this.weightStr = weightStr;
this.wrappedDataSource = wrappedDataSource;
this.dbType = dbType;
this.dataSourceIndex = dataSourceIndex;
}
示例5: getDataSourceWrapper
import com.taobao.tddl.common.model.DBType; //導入依賴的package包/類
public static DataSourceWrapper getDataSourceWrapper(String dsKey, String weightStr, int index,
DataSourceFetcher fetcher) {
// 如果多個group複用一個真實dataSource,會造成所有group引用
// 這個dataSource的配置 會以最後一個dataSource的配置為準
DataSource dataSource = fetcher.getDataSource(dsKey);
DBType fetcherDbType = fetcher.getDataSourceDBType(dsKey);
// dbType = fetcherDbType == null ? dbType :
// fetcherDbType;
DataSourceWrapper dsw = new DataSourceWrapper(dsKey, weightStr, dataSource, fetcherDbType, index);
return dsw;
}
示例6: setUpBeforeClass
import com.taobao.tddl.common.model.DBType; //導入依賴的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);
}
示例7: TGroupDataSource
import com.taobao.tddl.common.model.DBType; //導入依賴的package包/類
@Test
public void 單個數據庫() throws Exception {
TGroupDataSource ds = new TGroupDataSource();
DataSourceWrapper dsw = new DataSourceWrapper(DSKEY0, "rw", getMySQLDataSource(), DBType.MYSQL);
ds.init(dsw);
testCrud(ds);
}
示例8: DataSourceWrapper
import com.taobao.tddl.common.model.DBType; //導入依賴的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);
}
示例9: getMySQLDataSource
import com.taobao.tddl.common.model.DBType; //導入依賴的package包/類
@Test
public void 三個數據庫_測試db1可讀寫_db2與db3隻能讀() throws Exception {
DataSource ds0 = getMySQLDataSource(0);
DataSource ds1 = getMySQLDataSource(1);
DataSource ds2 = getMySQLDataSource(2);
// 讀庫時最有可能從db3讀,然後是db2,db1的權重最小
TGroupDataSource ds = new TGroupDataSource();
DataSourceWrapper dsw0 = new DataSourceWrapper(DSKEY0, "r10w", ds0, DBType.MYSQL);
DataSourceWrapper dsw1 = new DataSourceWrapper(DSKEY1, "r20", ds1, DBType.MYSQL);
DataSourceWrapper dsw2 = new DataSourceWrapper(DSKEY2, "r30", ds2, DBType.MYSQL);
ds.init(dsw0, dsw1, dsw2);
testCrud(ds);
}
示例10: getDbTypeEnumObj
import com.taobao.tddl.common.model.DBType; //導入依賴的package包/類
public DBType getDbTypeEnumObj() {
return DBType.valueOf(this.dbType);
}
示例11: setDbType
import com.taobao.tddl.common.model.DBType; //導入依賴的package包/類
public void setDbType(DBType dbType) {
this.dbType = dbType;
}
示例12: getDbType
import com.taobao.tddl.common.model.DBType; //導入依賴的package包/類
public DBType getDbType() {
return dbType;
}
示例13: setDbType
import com.taobao.tddl.common.model.DBType; //導入依賴的package包/類
public void setDbType(DBType dbType) {
this.dbType = dbType;
this.exceptionSorter = exceptionSorters.get(this.dbType);
}
示例14: getDBType
import com.taobao.tddl.common.model.DBType; //導入依賴的package包/類
public DBType getDBType() {
return dbType;
}