本文整理汇总了Java中com.taobao.tddl.atom.TAtomDataSource.setDbKey方法的典型用法代码示例。如果您正苦于以下问题:Java TAtomDataSource.setDbKey方法的具体用法?Java TAtomDataSource.setDbKey怎么用?Java TAtomDataSource.setDbKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.taobao.tddl.atom.TAtomDataSource
的用法示例。
在下文中一共展示了TAtomDataSource.setDbKey方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTAtomDataSource
import com.taobao.tddl.atom.TAtomDataSource; //导入方法依赖的package包/类
private TAtomDataSource createTAtomDataSource(String appName, String dbKey, String configName) throws IOException,
TddlException,
Exception {
// 全局配置
String globaStr = PropLoadTestUtil.loadPropFile2String("conf/" + configName + "/globa.properties");
MockServer.setConfigInfo(TAtomConstants.getGlobalDataId(dbKey), globaStr);
// 应用配置
String appStr = PropLoadTestUtil.loadPropFile2String("conf/" + configName + "/app.properties");
MockServer.setConfigInfo(TAtomConstants.getAppDataId(appName, dbKey), appStr);
// 解析配置
TAtomDsConfDO tAtomDsConfDO = TAtomConfParser.parserTAtomDsConfDO(globaStr, appStr);
// 密码配置
String passwdStr = PropLoadTestUtil.loadPropFile2String("conf/" + configName + "/passwd.properties");
MockServer.setConfigInfo(TAtomConstants.getPasswdDataId(tAtomDsConfDO.getDbName(),
tAtomDsConfDO.getDbType(),
tAtomDsConfDO.getUserName()), passwdStr);
// 进行初始化
TAtomDataSource tAtomDataSource = new TAtomDataSource();
tAtomDataSource.setAppName(appName);
tAtomDataSource.setDbKey(dbKey);
tAtomDataSource.init();
return tAtomDataSource;
}
示例2: createTAtomDataSource
import com.taobao.tddl.atom.TAtomDataSource; //导入方法依赖的package包/类
private TAtomDataSource createTAtomDataSource(String appName, String dbKey, String configName)
throws IOException,
AtomAlreadyInitException,
Exception {
// 全局配置
String globaStr = PropLoadTestUtil.loadPropFile2String("conf/" + configName + "/globa.properties");
MockServer.setConfigInfo(TAtomConstants.getGlobalDataId(dbKey), globaStr);
// 应用配置
String appStr = PropLoadTestUtil.loadPropFile2String("conf/" + configName + "/app.properties");
MockServer.setConfigInfo(TAtomConstants.getAppDataId(appName, dbKey), appStr);
// 解析配置
TAtomDsConfDO tAtomDsConfDO = TAtomConfParser.parserTAtomDsConfDO(globaStr, appStr);
// 密码配置
String passwdStr = PropLoadTestUtil.loadPropFile2String("conf/" + configName + "/passwd.properties");
MockServer.setConfigInfo(TAtomConstants.getPasswdDataId(tAtomDsConfDO.getDbName(),
tAtomDsConfDO.getDbType(),
tAtomDsConfDO.getUserName()), passwdStr);
// 进行初始化
TAtomDataSource tAtomDataSource = new TAtomDataSource();
tAtomDataSource.setAppName(appName);
tAtomDataSource.setDbKey(dbKey);
tAtomDataSource.init();
return tAtomDataSource;
}
示例3: main
import com.taobao.tddl.atom.TAtomDataSource; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
TAtomDataSource ds = new TAtomDataSource();
ds.setDbKey("my193179_sqa_yh_mydevice_3407");
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("SELECT * from sample_table a where a.id = any (select id from sample_table where id='1')");
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");
}
示例4: setUp
import com.taobao.tddl.atom.TAtomDataSource; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
setAtomMockInfo(ATOM_NORMAL_0_PATH, APPNAME, DBKEY_0);
tds = new TAtomDataSource();
tds.setAppName(APPNAME);
tds.setDbKey(DBKEY_0);
tds.init();
tddlJT = getJT();
}
示例5: getJT
import com.taobao.tddl.atom.TAtomDataSource; //导入方法依赖的package包/类
protected static JdbcTemplate getJT(String path, String appName, String dbKey) throws Exception {
setAtomMockInfo(path, appName, dbKey);
TAtomDataSource atomDs = new TAtomDataSource();
atomDs.setAppName(appName);
atomDs.setDbKey(dbKey);
atomDs.init();
return new JdbcTemplate(atomDs);
}