本文整理汇总了Java中com.ibatis.common.resources.Resources类的典型用法代码示例。如果您正苦于以下问题:Java Resources类的具体用法?Java Resources怎么用?Java Resources使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Resources类属于com.ibatis.common.resources包,在下文中一共展示了Resources类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: initScript
import com.ibatis.common.resources.Resources; //导入依赖的package包/类
protected static void initScript(String script) throws Exception {
DataSource ds = sqlMap.getDataSource();
Connection conn = ds.getConnection();
Reader reader = Resources.getResourceAsReader(script);
ScriptRunner runner = new ScriptRunner(conn, false, false);
runner.setLogWriter(null);
runner.setErrorLogWriter(null);
runner.runScript(reader);
conn.commit();
conn.close();
reader.close();
}
开发者ID:mybatis,项目名称:ibatis-2,代码行数:17,代码来源:BaseSqlMapTest.java
示例2: runTest
import com.ibatis.common.resources.Resources; //导入依赖的package包/类
private void runTest(String statementToRun) throws IOException, SQLException {
String resource = "threads/sql-map-config.xml";
Reader reader = Resources.getResourceAsReader(resource);
SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
sqlMap.update("create");
int count = 2;
List<MyThread> threads = new LinkedList<MyThread>();
for (int i = 0; i < count; i++) {
MyThread thread = new MyThread(sqlMap, statementToRun);
thread.start();
threads.add(thread);
}
Date d1 = new Date(new Date().getTime() + 10000);
// let's do the test for 10 seconds - for me it failed quite early
while (new Date().before(d1)) {
for (MyThread myThread : threads) {
assertTrue(myThread.isAlive());
}
}
}
开发者ID:mybatis,项目名称:ibatis-2,代码行数:27,代码来源:RemapResultsThreadTest.java
示例3: testSimple
import com.ibatis.common.resources.Resources; //导入依赖的package包/类
@Test
public void testSimple() throws SQLException, IOException {
String resource = "org/n3r/sandbox/db/ibatis/sqlmap-config.xml";
Reader reader = Resources.getResourceAsReader(resource);
SqlMapClient sqlmap = SqlMapClientBuilder.buildSqlMapClient(reader);
HashMap<String, String> param = new HashMap<String, String>();
param.put("dataId", "a");
Object obj = sqlmap.queryForObject("test1", param);
System.out.println(obj);
}
开发者ID:bingoohuang,项目名称:javacode-demo,代码行数:11,代码来源:IbatisTest.java
示例4: initSqlMapClient
import com.ibatis.common.resources.Resources; //导入依赖的package包/类
private static SqlMapClient initSqlMapClient(String cfgName) throws Exception{
InputStream in = null;
SqlMapClient sqlMapClient = null;
try{
in = Resources.getResourceAsStream(cfgName);
sqlMapClient = new SqlMapConfigParser().parse(in);
}finally{
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return sqlMapClient;
}
开发者ID:yongzhidai,项目名称:GameServer,代码行数:16,代码来源:DBUtil.java
示例5: tryImplementation
import com.ibatis.common.resources.Resources; //导入依赖的package包/类
private static void tryImplementation(String testClassName, String implClassName) {
if (logConstructor == null) {
try {
Resources.classForName(testClassName);
Class implClass = Resources.classForName(implClassName);
logConstructor = implClass.getConstructor(new Class[] { Class.class });
} catch (Throwable t) {
}
}
}
开发者ID:mybatis,项目名称:ibatis-2,代码行数:11,代码来源:LogFactory.java
示例6: selectLog4JLogging
import com.ibatis.common.resources.Resources; //导入依赖的package包/类
/**
* This method will switch the logging implementation to Log4J if Log4J is available on the classpath. This is useful
* in situations where you want to use Log4J to log iBATIS activity but commons logging is on the classpath. Note that
* this method is only effective for log classes obtained after calling this method. If you intend to use this method
* you should call it before calling any other iBATIS method.
*
*/
public static synchronized void selectLog4JLogging() {
try {
Resources.classForName("org.apache.log4j.Logger");
Class implClass = Resources.classForName("com.ibatis.common.logging.log4j.Log4jImpl");
logConstructor = implClass.getConstructor(new Class[] { Class.class });
} catch (Throwable t) {
}
}
开发者ID:mybatis,项目名称:ibatis-2,代码行数:16,代码来源:LogFactory.java
示例7: selectJavaLogging
import com.ibatis.common.resources.Resources; //导入依赖的package包/类
/**
* This method will switch the logging implementation to Java native logging if you are running in JRE 1.4 or above.
* This is useful in situations where you want to use Java native logging to log iBATIS activity but commons logging
* or Log4J is on the classpath. Note that this method is only effective for log classes obtained after calling this
* method. If you intend to use this method you should call it before calling any other iBATIS method.
*/
public static synchronized void selectJavaLogging() {
try {
Resources.classForName("java.util.logging.Logger");
Class implClass = Resources.classForName("com.ibatis.common.logging.jdk14.Jdk14LoggingImpl");
logConstructor = implClass.getConstructor(new Class[] { Class.class });
} catch (Throwable t) {
}
}
开发者ID:mybatis,项目名称:ibatis-2,代码行数:15,代码来源:LogFactory.java
示例8: getPropertyTypeForSetter
import com.ibatis.common.resources.Resources; //导入依赖的package包/类
public Class getPropertyTypeForSetter(Object object, String name) {
Element e = findNestedNodeByName(resolveElement(object), name, false);
// todo alias types, don't use exceptions like this
try {
return Resources.classForName(e.getAttribute("type"));
} catch (ClassNotFoundException e1) {
return Object.class;
}
}
开发者ID:mybatis,项目名称:ibatis-2,代码行数:10,代码来源:DomProbe.java
示例9: getPropertyTypeForGetter
import com.ibatis.common.resources.Resources; //导入依赖的package包/类
public Class getPropertyTypeForGetter(Object object, String name) {
Element e = findNestedNodeByName(resolveElement(object), name, false);
// todo alias types, don't use exceptions like this
try {
return Resources.classForName(e.getAttribute("type"));
} catch (ClassNotFoundException e1) {
return Object.class;
}
}
开发者ID:mybatis,项目名称:ibatis-2,代码行数:10,代码来源:DomProbe.java
示例10: setJavaTypeName
import com.ibatis.common.resources.Resources; //导入依赖的package包/类
public void setJavaTypeName(String javaTypeName) {
try {
if (javaTypeName == null) {
this.javaType = null;
} else {
this.javaType = Resources.classForName(javaTypeName);
}
} catch (ClassNotFoundException e) {
throw new SqlMapException("Error setting javaType property of ParameterMap. Cause: " + e, e);
}
}
开发者ID:mybatis,项目名称:ibatis-2,代码行数:12,代码来源:ParameterMapping.java
示例11: setUp
import com.ibatis.common.resources.Resources; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
initSqlMap("com/ibatis/sqlmap/maps/DerbySqlMapConfig.xml",
Resources.getResourceAsProperties("com/ibatis/sqlmap/maps/DerbySqlMapConfig.properties"));
initScript("scripts/account-init.sql");
initScript("scripts/derby-proc-init.sql");
}
开发者ID:mybatis,项目名称:ibatis-2,代码行数:9,代码来源:MultiResultSetTest.java
示例12: testOrgSqlMapInsertTimeOut
import com.ibatis.common.resources.Resources; //导入依赖的package包/类
@Test
public void testOrgSqlMapInsertTimeOut() throws Exception {
if (!isHsql) {
Reader reader =
Resources
.getResourceAsReader("META-INF/sqlmap/sql-map-config-org.xml");
SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
try {
// insert ~ select
sqlMap.insert("insertTestLargeTimeOut");
fail("timeout 테스트이므로 더 시간이 많이 걸리는 쿼리를 사용해야 합니다.");
} catch (Exception e) {
assertNotNull(e);
assertTrue(e instanceof SQLException);
if (isOracle) {
assertTrue(e.getMessage().contains("ORA-01013"));
} else if (isMysql) {
assertTrue(e.getMessage().contains(
"Query execution was interrupted"));
}
}
}
}
开发者ID:eGovFrame,项目名称:egovframework.rte.root,代码行数:28,代码来源:TimeoutTest.java
示例13: initialize
import com.ibatis.common.resources.Resources; //导入依赖的package包/类
private void initialize(Map props) {
try {
String prop_pool_ping_query = null;
if (props == null) {
throw new RuntimeException("SimpleDataSource: The properties map passed to the initializer was null.");
}
if (!(props.containsKey(PROP_JDBC_DRIVER) && props.containsKey(PROP_JDBC_URL)
&& props.containsKey(PROP_JDBC_USERNAME) && props.containsKey(PROP_JDBC_PASSWORD))) {
throw new RuntimeException("SimpleDataSource: Some properties were not set.");
} else {
jdbcDriver = (String) props.get(PROP_JDBC_DRIVER);
jdbcUrl = (String) props.get(PROP_JDBC_URL);
jdbcUsername = (String) props.get(PROP_JDBC_USERNAME);
jdbcPassword = (String) props.get(PROP_JDBC_PASSWORD);
poolMaximumActiveConnections = props.containsKey(PROP_POOL_MAX_ACTIVE_CONN) ? Integer.parseInt((String) props
.get(PROP_POOL_MAX_ACTIVE_CONN)) : 10;
poolMaximumIdleConnections = props.containsKey(PROP_POOL_MAX_IDLE_CONN) ? Integer.parseInt((String) props
.get(PROP_POOL_MAX_IDLE_CONN)) : 5;
poolMaximumCheckoutTime = props.containsKey(PROP_POOL_MAX_CHECKOUT_TIME) ? Integer.parseInt((String) props
.get(PROP_POOL_MAX_CHECKOUT_TIME)) : 20000;
poolTimeToWait = props.containsKey(PROP_POOL_TIME_TO_WAIT) ? Integer.parseInt((String) props
.get(PROP_POOL_TIME_TO_WAIT)) : 20000;
poolPingEnabled = props.containsKey(PROP_POOL_PING_ENABLED)
&& Boolean.valueOf((String) props.get(PROP_POOL_PING_ENABLED)).booleanValue();
prop_pool_ping_query = (String) props.get(PROP_POOL_PING_QUERY);
poolPingQuery = props.containsKey(PROP_POOL_PING_QUERY) ? prop_pool_ping_query : "NO PING QUERY SET";
poolPingConnectionsOlderThan = props.containsKey(PROP_POOL_PING_CONN_OLDER_THAN) ? Integer
.parseInt((String) props.get(PROP_POOL_PING_CONN_OLDER_THAN)) : 0;
poolPingConnectionsNotUsedFor = props.containsKey(PROP_POOL_PING_CONN_NOT_USED_FOR) ? Integer
.parseInt((String) props.get(PROP_POOL_PING_CONN_NOT_USED_FOR)) : 0;
jdbcDefaultAutoCommit = props.containsKey(PROP_JDBC_DEFAULT_AUTOCOMMIT)
&& Boolean.valueOf((String) props.get(PROP_JDBC_DEFAULT_AUTOCOMMIT)).booleanValue();
useDriverProps = false;
Iterator propIter = props.keySet().iterator();
driverProps = new Properties();
driverProps.put("user", jdbcUsername);
driverProps.put("password", jdbcPassword);
while (propIter.hasNext()) {
String name = (String) propIter.next();
String value = (String) props.get(name);
if (name.startsWith(ADD_DRIVER_PROPS_PREFIX)) {
driverProps.put(name.substring(ADD_DRIVER_PROPS_PREFIX_LENGTH), value);
useDriverProps = true;
}
}
expectedConnectionTypeCode = assembleConnectionTypeCode(jdbcUrl, jdbcUsername, jdbcPassword);
Resources.instantiate(jdbcDriver);
if (poolPingEnabled && (!props.containsKey(PROP_POOL_PING_QUERY) || prop_pool_ping_query.trim().length() == 0)) {
throw new RuntimeException("SimpleDataSource: property '" + PROP_POOL_PING_ENABLED
+ "' is true, but property '" + PROP_POOL_PING_QUERY + "' is not set correctly.");
}
}
} catch (Exception e) {
log.error("SimpleDataSource: Error while loading properties. Cause: " + e.toString(), e);
throw new RuntimeException("SimpleDataSource: Error while loading properties. Cause: " + e, e);
}
}
开发者ID:mybatis,项目名称:ibatis-2,代码行数:75,代码来源:SimpleDataSource.java
示例14: initSqlMap
import com.ibatis.common.resources.Resources; //导入依赖的package包/类
protected static void initSqlMap(String configFile, Properties props) throws Exception {
Reader reader = Resources.getResourceAsReader(configFile);
sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader, props);
reader.close();
}
开发者ID:mybatis,项目名称:ibatis-2,代码行数:6,代码来源:BaseSqlMapTest.java
示例15: IBatis
import com.ibatis.common.resources.Resources; //导入依赖的package包/类
/**
* Additional constructor - this can be used for testing purposes or retrieving
* a different connection to what is defined inside the server properties.
*
* @param properties Properties containing 4 properties: -
* "driver", "url", "username" and "password".
* @throws IOException
*/
private IBatis (Properties properties) throws IOException {
// Set up default SQL map
Reader reader = Resources.getResourceAsReader(DEFAULT_SQLMAP);
this.sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader, properties);
}
开发者ID:lgsilvestre,项目名称:Jogre,代码行数:15,代码来源:IBatis.java
注:本文中的com.ibatis.common.resources.Resources类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论