- 浏览: 1234820 次
- 性别:
- 来自: 广州
-
博客专栏
-
-
Apache CXF使用s...
浏览量:112063
文章分类
- 全部博客 (189)
- Spring (13)
- Hibernate (10)
- liferay portal (3)
- Java (18)
- 数据库 (32)
- JS (12)
- Eclipse (16)
- Log4j (3)
- 我的收藏夹 (8)
- FF and IE (2)
- Groovy Grails (0)
- Web Service (16)
- Quartz (6)
- Tomcat (8)
- Linux (4)
- xml (4)
- Silverlight (1)
- Flex (10)
- JBoss (4)
- EJB (2)
- WAS(webSphere) (5)
- DOS命令 (2)
- JSON (2)
- Maven (1)
- OThers (1)
- SVN (1)
- iBatis (4)
- OS (1)
- 问题解决 (8)
- 待看文章 (2)
- 多线程 (2)
- 代码收藏(即拿即用工具类) (5)
- Socket (2)
- Android (4)
- 其他 (1)
- python (1)
- Genymotion (1)
最新评论
-
a807966224:
还是 多谢楼主 总结的挺好的 !!!
CXF 入门:创建一个基于SOAPHeader的安全验证(CXF拦截器使用) -
a807966224:
然后 通过 SOAPMessage.getHeader(qna ...
CXF 入门:创建一个基于SOAPHeader的安全验证(CXF拦截器使用) -
a807966224:
我也是接触这东西不久,QName qname = new QN ...
CXF 入门:创建一个基于SOAPHeader的安全验证(CXF拦截器使用) -
a807966224:
楼主 不知道你有没有出现 从headers 里取出来长 ...
CXF 入门:创建一个基于SOAPHeader的安全验证(CXF拦截器使用) -
xdc0209:
兄弟呀,报错啦 2011-12-15 13:27:15 n ...
Hibernate+EhCache配置二级缓存
1,在com.ibatis.sqlmap.engine.datasource包新增类C3P0DataSourceFactory:
package com.ibatis.sqlmap.engine.datasource; import com.ibatis.common.jdbc.C3P0Configuration; import java.util.Map; import javax.sql.DataSource; public class C3P0DataSourceFactory implements DataSourceFactory { private DataSource dataSource; public void initialize(Map map) { C3P0Configuration c3p0 = new C3P0Configuration(map); this.dataSource = c3p0.getDataSource(); } public DataSource getDataSource() { return this.dataSource; } }
2,在com.ibatis.common.jdbc包新增类C3P0Configuration ,主要作用是加载c3p0的配置文件信息:
package com.ibatis.common.jdbc; import com.ibatis.common.beans.Probe; import com.ibatis.common.beans.ProbeFactory; import com.ibatis.common.exception.NestedRuntimeException; import com.mchange.v2.c3p0.ComboPooledDataSource; import java.util.Iterator; import java.util.Map; import java.util.Set; import javax.sql.DataSource; import org.apache.commons.dbcp.BasicDataSource; public class C3P0Configuration { private static final Probe PROBE = ProbeFactory.getProbe(); private static final String ADD_DRIVER_PROPS_PREFIX = "Driver."; private static final int ADD_DRIVER_PROPS_PREFIX_LENGTH = "Driver.".length(); private DataSource dataSource; public C3P0Configuration(Map properties) { try { this.dataSource = legacyC3P0Configuration(properties); if (this.dataSource == null) this.dataSource = newDbcpConfiguration(properties); } catch (Exception e) { throw new NestedRuntimeException("Error initializing C3P0DataSourceFactory. Cause: " + e, e); } } public DataSource getDataSource() { return this.dataSource; } private BasicDataSource newDbcpConfiguration(Map map) { BasicDataSource basicDataSource = new BasicDataSource(); Iterator props = map.keySet().iterator(); while (props.hasNext()) { String propertyName = (String)props.next(); if (propertyName.startsWith("Driver.")) { String value = (String)map.get(propertyName); basicDataSource.addConnectionProperty(propertyName.substring(ADD_DRIVER_PROPS_PREFIX_LENGTH), value); } else if (PROBE.hasWritableProperty(basicDataSource, propertyName)) { String value = (String)map.get(propertyName); Object convertedValue = convertValue(basicDataSource, propertyName, value); PROBE.setObject(basicDataSource, propertyName, convertedValue); } } return basicDataSource; } private Object convertValue(Object object, String propertyName, String value) { Object convertedValue = value; Class targetType = PROBE.getPropertyTypeForSetter(object, propertyName); if ((targetType == Integer.class) || (targetType == Integer.TYPE)) convertedValue = Integer.valueOf(value); else if ((targetType == Long.class) || (targetType == Long.TYPE)) convertedValue = Long.valueOf(value); else if ((targetType == Boolean.class) || (targetType == Boolean.TYPE)) { convertedValue = Boolean.valueOf(value); } return convertedValue; } private ComboPooledDataSource legacyC3P0Configuration(Map map) throws Exception { ComboPooledDataSource basicDataSource = null; if (map.containsKey("driver")) { basicDataSource = new ComboPooledDataSource(); String driver = (String)map.get("driver"); String url = (String)map.get("url"); String username = (String)map.get("username"); String password = (String)map.get("password"); String initialPoolSize = (String)map.get("initialPoolSize"); String maxPoolSize = (String)map.get("maxPoolSize"); String minPoolSize = (String)map.get("minPoolSize"); String acquireIncrement = (String)map.get("acquireIncrement"); String maxIdleTime = (String)map.get("maxIdleTime"); String maxIdleTimeExcessConnections = (String)map.get("maxIdleTimeExcessConnections"); String maxConnectionAge = (String)map.get("maxConnectionAge"); String maxStatements = (String)map.get("maxStatements"); String maxStatementsPerConnection = (String)map.get("maxStatementsPerConnection"); String numHelperThreads = (String)map.get("numHelperThreads"); String automaticTestTable = (String)map.get("automaticTestTable"); String preferredTestQuery = (String)map.get("preferredTestQuery"); String checkoutTimeout = (String)map.get("checkoutTimeout"); String idleConnectionTestPeriod = (String)map.get("idleConnectionTestPeriod"); String acquireRetryDelay = (String)map.get("acquireRetryDelay"); String acquireRetryAttempts = (String)map.get("acquireRetryAttempts"); String testConnectionOnCheckin = (String)map.get("testConnectionOnCheckin"); basicDataSource.setDriverClass(driver); basicDataSource.setJdbcUrl(url); basicDataSource.setUser(username); basicDataSource.setPassword(password); if (notEmpty(automaticTestTable)) { basicDataSource.setAutomaticTestTable(automaticTestTable); } if (notEmpty(acquireRetryDelay)) { basicDataSource.setAcquireRetryDelay(Integer.valueOf(acquireRetryDelay).intValue()); } if (notEmpty(testConnectionOnCheckin)) { basicDataSource.setTestConnectionOnCheckin(Boolean.valueOf(testConnectionOnCheckin).booleanValue()); } if (notEmpty(acquireRetryAttempts)) { basicDataSource.setAcquireRetryAttempts(Integer.valueOf(acquireRetryAttempts).intValue()); } if (notEmpty(preferredTestQuery)) { basicDataSource.setPreferredTestQuery(preferredTestQuery); } if (notEmpty(checkoutTimeout)) { basicDataSource.setCheckoutTimeout(Integer.valueOf(checkoutTimeout).intValue()); } if (notEmpty(checkoutTimeout)) { basicDataSource.setCheckoutTimeout(Integer.valueOf(checkoutTimeout).intValue()); } if (notEmpty(idleConnectionTestPeriod)) { basicDataSource.setIdleConnectionTestPeriod(Integer.valueOf(idleConnectionTestPeriod).intValue()); } if (notEmpty(initialPoolSize)) { basicDataSource.setInitialPoolSize(Integer.parseInt(initialPoolSize)); } if (notEmpty(maxPoolSize)) { basicDataSource.setMaxPoolSize(Integer.parseInt(maxPoolSize)); } if (notEmpty(minPoolSize)) { basicDataSource.setMinPoolSize(Integer.parseInt(minPoolSize)); } if (notEmpty(acquireIncrement)) { basicDataSource.setAcquireIncrement(Integer.parseInt(acquireIncrement)); } if (notEmpty(maxIdleTime)) { basicDataSource.setMaxIdleTime(Integer.parseInt(maxIdleTime)); } if (notEmpty(maxIdleTimeExcessConnections)) { basicDataSource.setMaxIdleTimeExcessConnections(Integer.parseInt(maxIdleTimeExcessConnections)); } if (notEmpty(maxConnectionAge)) { basicDataSource.setMaxConnectionAge(Integer.parseInt(maxConnectionAge)); } if (notEmpty(maxStatements)) { basicDataSource.setMaxStatements(Integer.parseInt(maxStatements)); } if (notEmpty(maxStatementsPerConnection)) { basicDataSource.setMaxStatementsPerConnection(Integer.parseInt(maxStatementsPerConnection)); } if (notEmpty(numHelperThreads)) { basicDataSource.setNumHelperThreads(Integer.parseInt(numHelperThreads)); } } return basicDataSource; } private boolean notEmpty(String s) { return (s != null) && (s.length() > 0); } }
3,在com.ibatis.sqlmap.engine.builder.xml下SqlMapConfigParser类的registerDefaultTypeAliases方法中添加如下代码:
this.vars.typeHandlerFactory.putTypeAlias("C3P0", C3P0DataSourceFactory.class.getName());
4,在com.ibatis.common.exception下新增异常处理类,如果没有此包,可以新建,代码见附件Exception.rar(NestedException.class , NestedRuntimeException.class)
5, ibatis配置文件如下,注意property中的name必须和下面一致:
<transactionManager type="JDBC">
<dataSource type="C3P0">
<property name="driver" value="${driver}" />
<property name="url" value="${url}" />
<property name="username" value="${username}" />
<property name="password" value="${password}" />
<property name="initialPoolSize" value="10" />
<property name="maxPoolSize" value="100" />
<property name="minPoolSize" value="10" />
<property name="acquireIncrement" value="5" />
<property name="maxIdleTime" value="3600" />
<property name="maxIdleTimeExcessConnections" value="1200" />
<property name="maxConnectionAge" value="27000" />
<property name="maxStatements" value="200" />
<property name="maxStatementsPerConnection" value="50" />
<property name="numHelperThreads" value="10" />
<property name="idleConnectionTestPeriod" value="5" />
<property name="checkoutTimeout" value="30000"/>
<property name="preferredTestQuery" value="select 1"/>
<property name="acquireRetryDelay" value="1000"/>
<property name="acquireRetryAttempts" value="1"/>
<property name="testConnectionOnCheckin" value="true"/>
<property name="automaticTestTable" value="c3p0Test"/>
</dataSource>
</transactionManager>
配置中只支持如上属性配置,如果需要加额外属性请在第二步的C3P0Configuration类的legacyC3P0Configuration方法中增加
附件ibatis-2.3.0.677.jar包是已扩展,无需修改
增加c3p0支持包:c3p0-0.9.1.2.jar
PS: 以上只限ibatis-2.3.0.677版本,其他版本按照此方式未必行得通
以下亲测可用
PS: 以下只限ibatis-2.3.0.677版本
- exception.rar (1.9 KB)
- 下载次数: 34
- ibatis-2.3.0.677.jar (380.9 KB)
- 下载次数: 63
- c3p0-0.9.1.2.jar (596.5 KB)
- 下载次数: 41
发表评论
-
解决sybase:Net-Lib protocol driver call to connect two endpoints failed
2014-08-08 17:11 491615:43:20.717 Program ) ct_con ... -
解决:Connections could not be acquired from the underlying database!
2013-07-30 14:31 293233og4j:WARN See http://logging. ... -
解决:Starting MySQL....The server quit without updating PID file
2013-01-21 12:10 2318控制台异常: Starting MySQL....The ... -
Mysql避免全表扫描sql查询优化 .
2012-12-07 13:29 5136对查询进行 ... -
inux下mysql的root密码忘记解决方
2012-10-15 11:53 1090FROM: http://www.cnblogs.com/a ... -
解决: Failed to obtain license(s) for ASE_CORE feature from license file(s)
2012-10-15 10:34 4622兔年第一个工作日,本打算收收利市、聊聊春节见闻就过去了,没想 ... -
解决Using locale name "zh_CN" defined in environment variable LANG
2012-09-06 13:07 2789The context allocation routine ... -
Sybase ASE ddlgen导出表结构
2012-08-31 13:22 2440事先配置好必要的环境变量,如果有则不用 export SYB ... -
修改sybase字符集排序
2012-08-31 13:14 1953sp_configure "default s ... -
bcp命令详解
2012-07-31 13:47 3432导入(导出把in改为out即可) bcp 数据库名..表 ... -
解决can't open a connection to site 'syb_backup'
2012-07-31 13:45 3409今天在恢复一个sybase数据库备份时,在执行load ... -
PowerDesigner15官方正式版注册补丁
2012-01-09 18:31 1429PowerDesigner15官方正式版注册补丁 -
SELECT INTO FROM与INSERT INTO SELECT 语法
2011-12-28 15:04 23481.INSERT INTO SELE ... -
Sybase数据库优化手册
2011-12-24 22:56 2491FROM :baidu wen ku 目 录 ... -
Sybase 数据库查询索引优化
2011-12-24 22:43 2870Sybase 数据库查询索引优化 一、实验目的 ... ... -
如何让你的SQL运行得更快
2011-12-24 21:56 1435人们在使用SQL时往往 ... -
数据库设计中的14个技巧
2011-12-24 21:40 1238FROM: http://blog.csdn.net/s ... -
解决:Cannot create PoolableConnectionFactory(Sybase)
2011-12-22 13:54 27801,首先确定数据库正常启动并且可以访问 2,程序里出现此问题 ... -
解决:mysql 忘记密码
2011-12-11 11:23 1245FROM:http://yaoyanzhu.itey ... -
@@IDENTITY与SCOPE_IDENTITY()
2011-12-09 13:33 5015Sybase 中不支持scope_ident ...
相关推荐
本压缩包"ibatisv230677.zip"包含了Ibatis 2.3.0.677版本的jar包和一份使用说明,对于正在学习Java、特别是Spring+Ibatis集成的开发者来说,这是一个非常有价值的资源。 Ibatis 的核心理念是将SQL语句写在XML配置...
- `ibatis-2.3.0.677.jar`:MyBatis的早期版本,也可能用于数据库操作,与Hibernate共同使用或替换部分功能。 5. **功能模块**: - **人力资源档案管理**:包括员工基本信息录入、修改、查询等操作。 - **调动...
scratch少儿编程逻辑思维游戏源码-米克 demo.zip
scratch少儿编程逻辑思维游戏源码-萝卜男孩拯救世界.zip
scratch少儿编程逻辑思维游戏源码-酷忍者.zip
教育科技_微信小程序_二手交易平台_大学校园二手书与物品循环利用公益系统_风华读书人校园二手交易平台_基于C2C模式的校内闲置物品交易系统_支持多校区独立运营的二手书交易平台_包含
全新UI彩虹外链网盘系统源码前后端美化模板整站 模版文件.zip
maoxig_nonebot-plugin-ai-timetable_32152_1745865455265
少儿编程scratch项目源代码文件案例素材-足球顶尖高手.zip
少儿编程scratch项目源代码文件案例素材-作战基地.zip
少儿编程scratch项目源代码文件案例素材-云端之上 1-4名玩家.zip
scratch少儿编程逻辑思维游戏源码-魔幻之塔.zip
scratch少儿编程逻辑思维游戏源码-楼层酷跑.zip
scratch少儿编程逻辑思维游戏源码-圈.zip
少儿编程scratch项目源代码文件案例素材-纸片马里奥自定义战役.zip
少儿编程scratch项目源代码文件案例素材-自由下落.zip
少儿编程scratch项目源代码文件案例素材-阻击蜈蚣.zip
健康监测与疾病预防_脉搏波分析_六轴加速度传感器_生理参数融合_STC12硬件采集_Android数据处理_SpringBoot后端_MySQL数据库_MatlabPython实验
音乐流媒体应用开发_基于JetpackCompose的跨平台开发_网易云音乐风格的多终端音乐播放器_包含手机平板电视手表四端适配的现代化音乐播放应用实现音乐发现播放列表管理个性化推