- 浏览: 1225387 次
- 性别:
- 来自: 广州
博客专栏
-
Apache CXF使用s...
浏览量:111303
文章分类
- 全部博客 (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 478715:43:20.717 Program ) ct_con ... -
解决:Connections could not be acquired from the underlying database!
2013-07-30 14:31 293028og4j:WARN See http://logging. ... -
解决:Starting MySQL....The server quit without updating PID file
2013-01-21 12:10 2281控制台异常: Starting MySQL....The ... -
Mysql避免全表扫描sql查询优化 .
2012-12-07 13:29 5098对查询进行 ... -
inux下mysql的root密码忘记解决方
2012-10-15 11:53 1060FROM: http://www.cnblogs.com/a ... -
解决: Failed to obtain license(s) for ASE_CORE feature from license file(s)
2012-10-15 10:34 4525兔年第一个工作日,本打算收收利市、聊聊春节见闻就过去了,没想 ... -
解决Using locale name "zh_CN" defined in environment variable LANG
2012-09-06 13:07 2739The context allocation routine ... -
Sybase ASE ddlgen导出表结构
2012-08-31 13:22 2402事先配置好必要的环境变量,如果有则不用 export SYB ... -
修改sybase字符集排序
2012-08-31 13:14 1879sp_configure "default s ... -
bcp命令详解
2012-07-31 13:47 3386导入(导出把in改为out即可) bcp 数据库名..表 ... -
解决can't open a connection to site 'syb_backup'
2012-07-31 13:45 3378今天在恢复一个sybase数据库备份时,在执行load ... -
PowerDesigner15官方正式版注册补丁
2012-01-09 18:31 1391PowerDesigner15官方正式版注册补丁 -
SELECT INTO FROM与INSERT INTO SELECT 语法
2011-12-28 15:04 23181.INSERT INTO SELE ... -
Sybase数据库优化手册
2011-12-24 22:56 2453FROM :baidu wen ku 目 录 ... -
Sybase 数据库查询索引优化
2011-12-24 22:43 2805Sybase 数据库查询索引优化 一、实验目的 ... ... -
如何让你的SQL运行得更快
2011-12-24 21:56 1399人们在使用SQL时往往 ... -
数据库设计中的14个技巧
2011-12-24 21:40 1194FROM: http://blog.csdn.net/s ... -
解决:Cannot create PoolableConnectionFactory(Sybase)
2011-12-22 13:54 27051,首先确定数据库正常启动并且可以访问 2,程序里出现此问题 ... -
解决:mysql 忘记密码
2011-12-11 11:23 1186FROM:http://yaoyanzhu.itey ... -
@@IDENTITY与SCOPE_IDENTITY()
2011-12-09 13:33 4956Sybase 中不支持scope_ident ...
相关推荐
这里提到的是iBATIS的三个不同版本的jar包:ibatis-2.3.4.726.jar、ibatis-2.3.0.677.jar以及ibatis-2.3.3.720.jar。 首先,让我们深入了解iBATIS的核心概念和功能: 1. **SQL Map配置**:iBATIS的核心是SQL Map...
ibatis-2.3.3.720.jar
使用Ibatis时,首先需要在项目中引入ibatis-2.3.0.677.jar,并配置相应的配置文件(如`sqlMapConfig.xml`),然后创建Mapper接口和对应的XML映射文件,最后在业务逻辑中通过SqlSession执行SQL语句。这个版本的Ibatis...
ibatis-2.3.0.677-sources.jar 值得学习的源码资源,不容错过。
标题 "ibatis-2.3.0.677.jar" 指向的是一个特定版本的 iBATIS 库,即版本号为 2.3.0.677 的 JAR 文件。iBATIS 是一个开源的 Java 框架,主要用于简化数据库与应用程序之间的交互。它在早期广泛应用于企业级应用开发...
在本主题中,我们将深入探讨Ibatis的两个特定版本:ibatis2.3.4.8.jar和ibatis-2.3.4.726.jar。 Ibatis的核心概念包括映射器(Mapper)、SQL映射文件和SqlSession。映射器是Ibatis的主要组件,它定义了数据库操作与...
ibatis-2.3.3.7.jar
《深入解析iBatis-SQLMap 2.3.4.726源码》 在Java开发领域,iBatis作为一个优秀的持久层框架,深受广大开发者喜爱。它将SQL语句与Java代码分离,提高了代码的可读性和可维护性。本篇将围绕iBatis-SQLMap 2.3.4.726...
ibatis-2.3.4.726最新API chm格式 非常好用
在实际使用Ibatis时,首先需要在项目中引入ibatis-2.3.0.677.jar包,然后配置SqlMapConfig.xml文件,这是整个Ibatis的全局配置文件,用于设置数据源、事务管理器以及其他核心组件。接下来,开发者可以创建具体的...
ibatis-2.3.0.677 ibatis-2.3.0.677 ibatis-2.3.0.677 ibatis-2.3.0.677 ibatis-2.3.0.677 ibatis-2.3.0.677 ibatis-2.3.0.677
ibatis的jar包com.springsource.com.ibatis-2.3.0.677.jar
该版本的iBatis jar文件,即`ibatis-2.3.0.677.jar`,包含了框架的所有核心类和库。其中,包含了SqlMapConfig.xml配置文件,这是iBatis系统的核心,用于定义数据源、事务管理器、SqlMapClient等重要组件。此外,还...
在这个2.3.4.726版本的源码中,我们可以深入理解iBATIS DAO的工作原理,并通过添加注释来帮助我们更好地掌握其实现细节。 首先,iBATIS DAO的核心概念是SQL Maps,它们定义了数据库操作的SQL语句,并将其映射到Java...
ibatis-2.3.4.732.jar
《深入解析iBatis 2.3.2.715源代码》 iBatis,作为一款轻量级的Java持久层框架,以其灵活、高效的特点,在许多项目中得到了广泛应用。本文将针对iBatis的2.3.2.715版本的源代码进行深入剖析,旨在帮助开发者更好地...
3. 数据源配置:`ibatis-2.3.2.715.jar`包含对数据源的支持,允许开发者配置连接池,提高数据库连接的复用,降低系统资源消耗。例如,它可以与C3P0、DBCP等连接池配合使用。 4. 参数映射与结果映射:Ibatis提供了...
总的来说,"ibatis-2.3.4.726官方最新开发包"是Java开发者进行数据库操作的强大工具,它简化了数据库操作,提升了开发效率,并且提供了丰富的文档支持,使得学习和使用变得更加容易。如果你正准备使用或升级Ibatis,...
iBATIS-2.3.0.677-Api文档