當前位置: 首頁>>代碼示例>>Java>>正文


Java DBType類代碼示例

本文整理匯總了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!");
        }
    }
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:19,代碼來源:GroupConfigManager.java

示例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;
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:20,代碼來源:GroupConfigManager.java

示例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而這裏沒有更新");
    }
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:12,代碼來源:MockDataSource.java

示例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;
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:11,代碼來源:DataSourceWrapper.java

示例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;
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:12,代碼來源:GroupConfigManager.java

示例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);
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:12,代碼來源:TGroupStatementTest.java

示例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);
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:9,代碼來源:CrudTest.java

示例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);
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:13,代碼來源:CrudTest.java

示例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);
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:16,代碼來源:CrudTest.java

示例10: getDbTypeEnumObj

import com.taobao.tddl.common.model.DBType; //導入依賴的package包/類
public DBType getDbTypeEnumObj() {
    return DBType.valueOf(this.dbType);
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:4,代碼來源:VirtualTableRoot.java

示例11: setDbType

import com.taobao.tddl.common.model.DBType; //導入依賴的package包/類
public void setDbType(DBType dbType) {
    this.dbType = dbType;
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:4,代碼來源:TableRule.java

示例12: getDbType

import com.taobao.tddl.common.model.DBType; //導入依賴的package包/類
public DBType getDbType() {
    return dbType;
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:4,代碼來源:TableRule.java

示例13: setDbType

import com.taobao.tddl.common.model.DBType; //導入依賴的package包/類
public void setDbType(DBType dbType) {
    this.dbType = dbType;
    this.exceptionSorter = exceptionSorters.get(this.dbType);
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:5,代碼來源:AbstractDBSelector.java

示例14: getDBType

import com.taobao.tddl.common.model.DBType; //導入依賴的package包/類
public DBType getDBType() {
    return dbType;
}
 
開發者ID:loye168,項目名稱:tddl5,代碼行數:4,代碼來源:DataSourceWrapper.java


注:本文中的com.taobao.tddl.common.model.DBType類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。