- 浏览: 29477 次
- 性别:
- 来自: 深圳
web.xml配置文件需要添加请求分发
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:applicationContext*.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Spring mappings -->
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
applicationContext配置文件
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<description>Spring公共配置文件</description>
<!-- mes 的數據庫 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value=""/>
<property name="jdbcUrl" value=""/>
<property name="user" value=""/>
<property name="password" value=""/>
<property name="maxPoolSize" value="10"></property>
<property name="maxIdleTime" value="1800"></property>
<property name="minPoolSize" value="1"></property>
<property name="initialPoolSize" value="1"></property>
</bean>
<bean id="dataSourcePdm" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value=""/>
<property name="jdbcUrl" value=""/>
<property name="user" value=""/>
<property name="password" value=""/>
<property name="maxPoolSize" value="10"></property>
<property name="maxIdleTime" value="1800"></property>
<property name="minPoolSize" value="1"></property>
<property name="initialPoolSize" value="1"></property>
</bean>
<bean id="dataSourceProxy"
class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy"
p:targetDataSource-ref="dataSource"/>
<bean id="localeResolver"
class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
<property name="cookieName">
<value>mes_locale</value>
</property>
<property name="cookieMaxAge">
<value>31536000</value>
</property>
</bean>
<!-- Mapping exception to the handler view
<bean id="exceptionResolover"
class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="defaultErrorView">
<value>/common/error/error</value>
</property>
<property name="exceptionMappings">
<props>
<prop key="com.ccc.exception.BusinessException">/common/error/businessError</prop>
<prop key="java.sql.SQLException">/common/error/error</prop>
<prop key="java.lang.RuntimeExcption">/common/error/error</prop>
</props>
</property>
</bean>
-->
<bean id="jstlViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/"/>
<property name="suffix" value=".jsp"/>
</bean>
<bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping">
<property name="order" value="2" />
</bean>
<context:component-scan base-package="com.ccc"/>
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"
p:order="0" />
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager "
p:dataSource-ref="dataSourceProxy"/>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="insert*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="allManagerMethod" expression="execution(* com.ccc..*.*(..))"/>
<aop:advisor pointcut-ref="allManagerMethod" advice-ref="txAdvice"/>
</aop:config>
<bean id="transactionManagerPdm" class="org.springframework.jdbc.datasource.DataSourceTransactionManager "
p:dataSource-ref="dataSourcePdm"/>
<tx:advice id="txAdvicePdm" transaction-manager="transactionManagerPdm">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="insert*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="allManagerMethodPdm" expression="execution(* com.ccc.pdm..*.*(..))"/>
<aop:advisor pointcut-ref="allManagerMethodPdm" advice-ref="txAdvicePdm"/>
</aop:config>
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean" p:dataSource-ref="dataSourceProxy">
<property name="configLocation">
<value>classpath:SqlMapConfig.xml</value>
</property>
</bean>
<bean id="sqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
<property name="sqlMapClient">
<ref bean="sqlMapClient" />
</property>
</bean>
<bean id="doubleSubmitInterceptor" class="com.ccc.filter.DoubleSubmitInterceptor">
<property name="mappingURL" value=".html" />
<property name="viewURL" value=".html" />
</bean>
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" p:order="0">
<property name="interceptors">
<list>
<ref bean="doubleSubmitInterceptor"/>
</list>
</property>
</bean>
-->
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource"><ref bean="dataSourceProxy"/></property>
</bean>
</beans>
JdbcTemplate实现
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:applicationContext*.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Spring mappings -->
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
applicationContext配置文件
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<description>Spring公共配置文件</description>
<!-- mes 的數據庫 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value=""/>
<property name="jdbcUrl" value=""/>
<property name="user" value=""/>
<property name="password" value=""/>
<property name="maxPoolSize" value="10"></property>
<property name="maxIdleTime" value="1800"></property>
<property name="minPoolSize" value="1"></property>
<property name="initialPoolSize" value="1"></property>
</bean>
<bean id="dataSourcePdm" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value=""/>
<property name="jdbcUrl" value=""/>
<property name="user" value=""/>
<property name="password" value=""/>
<property name="maxPoolSize" value="10"></property>
<property name="maxIdleTime" value="1800"></property>
<property name="minPoolSize" value="1"></property>
<property name="initialPoolSize" value="1"></property>
</bean>
<bean id="dataSourceProxy"
class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy"
p:targetDataSource-ref="dataSource"/>
<bean id="localeResolver"
class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
<property name="cookieName">
<value>mes_locale</value>
</property>
<property name="cookieMaxAge">
<value>31536000</value>
</property>
</bean>
<!-- Mapping exception to the handler view
<bean id="exceptionResolover"
class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="defaultErrorView">
<value>/common/error/error</value>
</property>
<property name="exceptionMappings">
<props>
<prop key="com.ccc.exception.BusinessException">/common/error/businessError</prop>
<prop key="java.sql.SQLException">/common/error/error</prop>
<prop key="java.lang.RuntimeExcption">/common/error/error</prop>
</props>
</property>
</bean>
-->
<bean id="jstlViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/"/>
<property name="suffix" value=".jsp"/>
</bean>
<bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping">
<property name="order" value="2" />
</bean>
<context:component-scan base-package="com.ccc"/>
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"
p:order="0" />
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager "
p:dataSource-ref="dataSourceProxy"/>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="insert*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="allManagerMethod" expression="execution(* com.ccc..*.*(..))"/>
<aop:advisor pointcut-ref="allManagerMethod" advice-ref="txAdvice"/>
</aop:config>
<bean id="transactionManagerPdm" class="org.springframework.jdbc.datasource.DataSourceTransactionManager "
p:dataSource-ref="dataSourcePdm"/>
<tx:advice id="txAdvicePdm" transaction-manager="transactionManagerPdm">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="insert*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="allManagerMethodPdm" expression="execution(* com.ccc.pdm..*.*(..))"/>
<aop:advisor pointcut-ref="allManagerMethodPdm" advice-ref="txAdvicePdm"/>
</aop:config>
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean" p:dataSource-ref="dataSourceProxy">
<property name="configLocation">
<value>classpath:SqlMapConfig.xml</value>
</property>
</bean>
<bean id="sqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate">
<property name="sqlMapClient">
<ref bean="sqlMapClient" />
</property>
</bean>
<bean id="doubleSubmitInterceptor" class="com.ccc.filter.DoubleSubmitInterceptor">
<property name="mappingURL" value=".html" />
<property name="viewURL" value=".html" />
</bean>
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" p:order="0">
<property name="interceptors">
<list>
<ref bean="doubleSubmitInterceptor"/>
</list>
</property>
</bean>
-->
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource"><ref bean="dataSourceProxy"/></property>
</bean>
</beans>
JdbcTemplate实现
import java.sql.SQLException; import java.util.List; import java.util.regex.PatternSyntaxException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.support.rowset.SqlRowSet; import org.springframework.jdbc.support.rowset.SqlRowSetMetaData; import org.springframework.stereotype.Service; import com.ccc.db.JdbcTemplateManager; import com.ccc.db.page.OraclePageOptimize; import com.ccc.tag.page.PagerTag; import com.ccc.util.BeanUtil; @Service("JdbcTemplateManager") public class JdbcTemplateManagerImpl implements JdbcTemplateManager { private static Log LOG = LogFactory.getLog(JdbcTemplateManagerImpl.class); @Autowired private JdbcTemplate jdbcTemplate; public String[][] executeQuery(String sql) throws SQLException { String sTmp; String[][] sArrRtn = null; int iCol = 0, i = 0, j = 0; boolean bFlg = false; SqlRowSet srs = null; SqlRowSetMetaData rsmd = null; srs = jdbcTemplate.queryForRowSet(sql); rsmd = srs.getMetaData(); iCol = rsmd.getColumnCount(); bFlg = srs.last(); if (bFlg) { i = srs.getRow(); } srs.beforeFirst(); sArrRtn = new String[i + 1][iCol]; for (i = 0; i < iCol; i++) { sTmp = rsmd.getColumnName(i + 1).trim(); sArrRtn[0][i] = sTmp; } while (srs.next()) { j = j + 1; for (i = 0; i < iCol; i++) { Object o = srs.getObject(i + 1); sTmp = String.valueOf(o == null ? "" : o); sTmp = sTmp.equalsIgnoreCase("null") ? "" : sTmp; sArrRtn[j][i] = sTmp; } } return sArrRtn; } public String[][] executeQuery(String sql, Object[] args) throws SQLException { String sTmp; String[][] sArrRtn = null; int iCol = 0, i = 0, j = 0; boolean bFlg = false; SqlRowSet srs = null; SqlRowSetMetaData rsmd = null; srs = jdbcTemplate.queryForRowSet(sql, args); rsmd = srs.getMetaData(); iCol = rsmd.getColumnCount(); bFlg = srs.last(); if (bFlg) { i = srs.getRow(); } srs.beforeFirst(); sArrRtn = new String[i + 1][iCol]; for (i = 0; i < iCol; i++) { sTmp = rsmd.getColumnName(i + 1).trim(); sArrRtn[0][i] = sTmp; } while (srs.next()) { j = j + 1; for (i = 0; i < iCol; i++) { Object o = srs.getObject(i + 1); sTmp = String.valueOf(o == null ? "" : o); sTmp = sTmp.equalsIgnoreCase("null") ? "" : sTmp; sArrRtn[j][i] = sTmp; } } return sArrRtn; } public List<?> queryForList(String sql, Object object) throws Exception { SqlRowSet srs = null; // srs = jdbcTemplate.queryForRowSet(sql); srs = (SqlRowSet) jdbcTemplate.query(sql, new SqlRowSetOracleResultSetExtractor()); List<?> list = BeanUtil.bindList(srs, BeanUtil.getClassName(object)); return list; } public List<?> queryForList(String sql, Object[] args, Object object) throws Exception { SqlRowSet srs = null; // srs = jdbcTemplate.queryForRowSet(sql, args); srs = (SqlRowSet) jdbcTemplate.query(sql, args, new SqlRowSetOracleResultSetExtractor()); List<?> list = BeanUtil.bindList(srs, BeanUtil.getClassName(object)); return list; } public Object queryForObject(String sql, Object object) throws Exception { SqlRowSet srs = null; // srs = jdbcTemplate.queryForRowSet(sql); srs = (SqlRowSet) jdbcTemplate.query(sql, new SqlRowSetOracleResultSetExtractor()); Object obj = BeanUtil.bindObject(srs, object); return obj; } public Object queryForObject(String sql, Object[] args, Object object) throws Exception { SqlRowSet srs = null; // srs = jdbcTemplate.queryForRowSet(sql, args); srs = (SqlRowSet) jdbcTemplate.query(sql, args, new SqlRowSetOracleResultSetExtractor()); Object obj = BeanUtil.bindObject(srs, object); return obj; } public int queryForInt(String sql) throws SQLException { int a = jdbcTemplate.queryForInt(sql); return a; } public int queryForInt(String sql, Object[] args) throws SQLException { int a = jdbcTemplate.queryForInt(sql, args); return a; } public long queryForLong(String sql) throws SQLException { long a = jdbcTemplate.queryForLong(sql); return a; } public long queryForLong(String sql, Object[] args) throws SQLException { long a = jdbcTemplate.queryForLong(sql, args); return a; } public String queryForString(String sql) throws SQLException { String str = (String) jdbcTemplate.queryForObject(sql, String.class); return str; } public String queryForString(String sql, Object[] args) throws SQLException { String str = (String) jdbcTemplate.queryForObject(sql, args, String.class); return str; } public List<?> queryForListPerPage(String sql, String sqlCount, PagerTag page, Object object) throws Exception { List<?> list = null; int recordCount = queryForInt(sqlCount); page.setRecordCount(recordCount); if (page.getRecordCount() <= 0) { } else { String osql = ""; OraclePageOptimize po = new OraclePageOptimize(); if (po != null) { osql = po.getOptimizeSQLString(page, sql); } else { osql = sql; } SqlRowSet srs = null; // srs = jdbcTemplate.queryForRowSet(osql); srs = (SqlRowSet) jdbcTemplate.query(osql, new SqlRowSetOracleResultSetExtractor()); list = BeanUtil.bindList(srs, BeanUtil.getClassName(object)); } return list; } public List<?> queryForListPerPage(String sql, String sqlCount, Object[] args, PagerTag page, Object object) throws Exception { List<?> list = null; int recordCount = queryForInt(sqlCount, args); page.setRecordCount(recordCount); if (page.getRecordCount() <= 0) { } else { String osql = ""; OraclePageOptimize po = new OraclePageOptimize(); if (po != null) { osql = po.getOptimizeSQLString(page, sql); } else { osql = sql; } SqlRowSet srs = null; //srs = jdbcTemplate.queryForRowSet(osql, args); srs = (SqlRowSet) jdbcTemplate.query(osql, args, new SqlRowSetOracleResultSetExtractor()); list = BeanUtil.bindList(srs, BeanUtil.getClassName(object)); } return list; } public long getSequencesNextValue(String sequencesName) throws SQLException { long sequencesValue = -1; String sql = "select " + sequencesName + ".NEXTVAL from dual"; sequencesValue = jdbcTemplate.queryForLong(sql); return sequencesValue; } public void executeUpdate(String sql) throws SQLException { jdbcTemplate.update(sql); } public void executeUpdate(String sql, Object[] args) throws SQLException { jdbcTemplate.update(sql, args); } public void batchUpdate(String[] sql) throws SQLException { jdbcTemplate.batchUpdate(sql); } public void batchUpdate(String sql, Object[][] args) throws SQLException { BatchPreparedStatementSetter setter = new BatchPreparedStatementSetter(); setter.setParam(args); jdbcTemplate.batchUpdate(sql, setter); } public void toSqlString(String sql, Object[] args) throws SQLException { String str = sql; try { if (args != null) { for (int i = 0; i < args.length; i++) { try { str = str.replaceFirst("\\?", "'" + args[i] + "'"); } catch (PatternSyntaxException e) { e.printStackTrace(); } } } else { LOG.error("DB.toSqlString:pram is null"); } } catch (Exception e) { LOG.error(e); } LOG.info(str); } }
相关推荐
c3p0配置文件
<c3p0-config> <!--默认配置--> <default-config> <property name="initialPoolSize">10</property> <property name="maxIdleTime">30</property> <property name="maxPoolSize">100</property> ...
c3p0 配置文件详细配置 C3P0 是一个流行的开源连接池实现,广泛应用于 Java 企业级应用中。C3P0 配置文件是关键的配置文件,用于控制连接池的行为。本文将详细介绍 C3P0 配置文件中的各个参数,并对其进行解释。 ...
4. **优化C3P0配置**:根据实际应用的负载情况,调整C3P0的配置参数,例如测试发现数据库访问高峰时经常出现连接不足的情况,可以适当增加`maxPoolSize`;如果服务器资源有限,可以降低`minPoolSize`以减少内存占用...
配置文件`c3p0-config.xml`是C3P0的配置文件,通过它可以设置C3P0连接池的各种参数,如初始连接数量、最大连接数量、超时时间、测试查询等。例如,你可以设置`minPoolSize`来定义连接池最小的连接数,`maxPoolSize`...
C3P0的配置主要通过`c3p0.properties`文件进行,其中包含了许多关键参数: - `minPoolSize`:最小连接池大小,初始化时创建的连接数量。 - `maxPoolSize`:最大连接池大小,池中允许的最大连接数。 - `...
配置C3P0连接池时,开发者通常需要在配置文件(如Hibernate的`hibernate.cfg.xml`或Spring的`applicationContext.xml`)中指定以下参数: - `driver_class`: 数据库驱动类名,例如`com.mysql.jdbc.Driver`。 - `...
C3P0 配置是通过一个 XML 文件(通常命名为 `c3p0-config.xml`)进行的,该文件包含了各种属性来调整连接池的行为和性能。以下是一些关键的 C3P0 配置属性的详细解释: 1. **acquireIncrement**: 这个属性定义了当...
Spring C3P0 配置详解 C3P0 是一个开源的 JDBC 连接池,它实现了数据源和 JNDI 绑定,支持 JUnit 和 Jakarta 构架。在 Spring 框架中集成 C3P0,可以有效地管理数据库连接,提高系统的性能和稳定性。下面我们将详细...
内容概要:c3p0连接池需要jar包.rar以及相关配置文件 C3P0是一个开源的JDBC连接池,它实现了数据源和JNDI绑定,支持JDBC3规范和JDBC2的标准扩展。目前使用它的开源项目有Hibernate、Spring等。 适合人群:正在学习...
**c3p0配置及jar包** c3p0是一个开源的JDBC连接池,它实现了数据源和JNDI绑定,支持JDBC3规范和JDBC2的标准扩展。在Spring框架中,c3p0作为数据库连接池的实现之一,能够有效地管理和优化数据库连接,提高系统的...
总结,Spring配置C3P0连接池涉及到添加依赖、在Spring配置文件中定义数据源bean以及配置C3P0的相关参数。通过这种方式,我们可以有效地管理和利用数据库连接,提高系统的稳定性和效率。在实际项目中,还需要根据具体...
2. **配置C3P0**:在Hibernate的配置文件(通常是`hibernate.cfg.xml`)中添加C3P0的相关配置,例如设置初始连接数、最大连接数、最小空闲连接数、超时时间等参数。 ```xml <property name="hibernate.c3p0.min_...
**c3p0配置文件和操作说明** c3p0是一个开源的JDBC连接池,它实现了数据源和JNDI绑定,支持JDBC3规范和JDBC2的标准扩展。在Java Web应用中,c3p0能有效地管理数据库连接,提高应用性能,避免频繁创建和关闭数据库...
以下是对C3P0配置中各个属性的详细解释: 1. `acquireIncrement`:当连接池中的连接耗尽时,C3P0一次性尝试获取的连接数。默认值为3,意味着如果连接池中没有可用连接,会尝试同时获取3个新的连接。 2. `...
C3P0的配置通常通过`c3p0.properties`文件完成,该文件一般位于项目的`WEB-INF\classes`目录下,确保被类加载器正确加载。配置文件中的参数众多,下面列举几个关键参数及其作用: - `c3p0.driverClass`:指定数据库...
### c3p0简易配置详解 c3p0是一个开源的JDBC连接池实现,它提供了对数据库连接的管理和优化,能够显著提升基于数据库的应用程序性能。本文将深入解析c30p配置中的关键参数,帮助理解其工作原理及如何进行有效配置。...
本示例主要讲解如何在Tomcat6中结合JNDI(Java Naming and Directory Interface)和C3P0库来配置数据库连接池,这对于初学者理解Web应用服务器与数据库的交互方式具有很大帮助。 首先,C3P0是一个开源的JDBC连接池...