256456
发贴: 91
积分: 50
|
于 2006-10-17 11:33
package com.bitfone.test;
import org.apache.log4j.Logger;
import com.ibatis.dao.client.Dao; import com.ibatis.dao.client.DaoManager; import com.ibatis.dao.engine.transaction.sqlmap.SqlMapDaoTransaction; import com.ibatis.sqlmap.client.SqlMapClient;
public class IbatisTest {
/** * @param args */ public static void main(String[] args) {
Logger log = Logger.getLogger(IbatisTest.class); log.debug("string test ...");
DaoManager daoManager = DaoConfig.getDaomanager();
BeanDAO dao = (BeanDAO) daoManager.getDao(BeanDAO.class); BeanDAO2 dao2 = (BeanDAO2) daoManager.getDao(BeanDAO2.class);
System.out.println("--- " + dao.getDate()); System.out.println("--- " + dao.getDate()); System.out.println("--- " + dao.getDate()); System.out.println("---2 " + dao2.getDate2()); System.out.println("---2 " + dao2.getDate2()); System.out.println("---2 " + dao2.getDate2());
Dao dao1 = daoManager.getDao(com.bitfone.test.BeanDAO.class); SqlMapClient sc = ((SqlMapDaoTransaction) daoManager .getTransaction(dao1)).getSqlMap(); sc.flushDataCache();
System.out.println("--- " + dao.getDate()); System.out.println("--- " + dao.getDate()); System.out.println("--- " + dao.getDate()); System.out.println("---2 " + dao2.getDate2()); System.out.println("---2 " + dao2.getDate2()); System.out.println("---2 " + dao2.getDate2());
}
}
----------------------------Device.xml---------------------------------
<cacheModel type="LRU" id="dateCache"> <flushInterval hours="12"/> <property value="1000" name="size"/> </cacheModel>
<select id="getDate" resultClass="string" cacheModel="dateCache"> SELECT sysdate FROM DUAL </select> ------------------------------Device2.xml------------------------------------------
<cacheModel type="LRU" id="dateCache2"> <flushInterval hours="12"/> <property value="1000" name="size"/> </cacheModel> <select id="getDate2" resultClass="string" cacheModel="dateCache2"> SELECT sysdate FROM DUAL </select>
=================================log info========================================= <DEBUG> 061017 11:27:08 <test.IbatisTest> string test ... <DEBUG> 061017 11:27:08 <test.IbatisTest> string test ... sql configuration OK <DEBUG> 061017 11:27:08 <jdbc.SimpleDataSource> Created connection 12258573. <DEBUG> 061017 11:27:08 <sql.Connection> {conn-100000} Connection <DEBUG> 061017 11:27:09 <jdbc.SimpleDataSource> Returned connection 12258573 to pool. --- 2006-10-17 11:22:46.0 --- 2006-10-17 11:22:46.0 --- 2006-10-17 11:22:46.0 <DEBUG> 061017 11:27:09 <jdbc.SimpleDataSource> Checked out connection 12258573 from pool. <DEBUG> 061017 11:27:09 <sql.Connection> {conn-100003} Connection <DEBUG> 061017 11:27:09 <jdbc.SimpleDataSource> Returned connection 12258573 to pool. ---2 2006-10-17 11:22:46.0 ---2 2006-10-17 11:22:46.0 ---2 2006-10-17 11:22:46.0 <DEBUG> 061017 11:27:09 <jdbc.SimpleDataSource> Checked out connection 12258573 from pool. <DEBUG> 061017 11:27:09 <sql.Connection> {conn-100006} Connection <DEBUG> 061017 11:27:09 <jdbc.SimpleDataSource> Returned connection 12258573 to pool. --- 2006-10-17 11:22:46.0 --- 2006-10-17 11:22:46.0 --- 2006-10-17 11:22:46.0 <DEBUG> 061017 11:27:09 <jdbc.SimpleDataSource> Checked out connection 12258573 from pool. <DEBUG> 061017 11:27:09 <sql.Connection> {conn-100009} Connection <DEBUG> 061017 11:27:09 <jdbc.SimpleDataSource> Returned connection 12258573 to pool. ---2 2006-10-17 11:22:46.0 ---2 2006-10-17 11:22:46.0 ---2 2006-10-17 11:22:46.0
|