weixin_42500637
2012-07-26 17:15
浏览 1.0k
已采纳

A ResourcePool could not acquire a resource from its primary factory or source

如题,本人从mysql数据库把里面的内容成功导入到sqlserver2005里 但是启动tomcat后会提示错误 ERROR org.hibernate.util.JDBCExceptionReporter - Connections could not be acquired from the underlying database,输入项目地址则会报500 错误信息如题!
spring配置文件如下:
<?xml version="1.0" encoding="UTF-8"?>
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"
default-lazy-init="true">

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <list>
            <value>/WEB-INF/config/jdbc.properties</value>
        </list>
    </property>
</bean>
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
    <property name="driverClass" value="${jdbc.driverClassName}" />
    <property name="jdbcUrl" value="${jdbc.url}" />
    <property name="user" value="${jdbc.username}" />
    <property name="password" value="${jdbc.password}" />
    <property name="autoCommitOnClose" value="true"/>
    <!-- <property name="checkoutTimeout" value="${cpool.checkoutTimeout}"/>-->
    <property name="initialPoolSize" value="${cpool.minPoolSize}"/>
    <property name="minPoolSize" value="${cpool.minPoolSize}"/>
    <property name="maxPoolSize" value="${cpool.maxPoolSize}"/>
    <property name="maxIdleTime" value="${cpool.maxIdleTime}"/>
    <property name="acquireIncrement" value="${cpool.acquireIncrement}"/>
    <property name="maxIdleTimeExcessConnections" value="${cpool.maxIdleTimeExcessConnections}"/>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource"/>  
    <property name="mappingLocations">
        <list>
            <value>classpath*:/com/jeecms/core/entity/hbm/*.hbm.xml</value>
            <value>classpath*:/com/jeecms/cms/entity/main/hbm/*.hbm.xml</value>
            <value>classpath*:/com/jeecms/cms/entity/assist/hbm/*.hbm.xml</value>
        </list>
    </property>
    <property name="hibernateProperties">
        <value>
        hibernate.dialect=org.hibernate.dialect.SQLServerDialect
        hibernate.show_sql=false
        hibernate.format_sql=false
        hibernate.query.substitutions=true 1, false 0
        hibernate.jdbc.batch_size=20
        hibernate.cache.use_query_cache=true
        </value>
    </property>
    <property name="entityInterceptor">   
        <ref local="treeInterceptor"/>
    </property>
    <property name="cacheProvider">
        <ref local="cacheProvider"/>
    </property>
    <property name="lobHandler">
        <ref bean="lobHandler" />
    </property>
</bean>
<bean id="lobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler" lazy-init="true"/>

<bean id="cacheProvider" class="com.jeecms.common.hibernate3.SpringEhCacheProvider">
    <property name="configLocation">
        <value>classpath:ehcache-hibernate.xml</value>
    </property>
    <property name="diskStoreLocation">
        <value>/WEB-INF/cache/hibernate</value>
    </property>
</bean>
<bean id="treeInterceptor" class="com.jeecms.common.hibernate3.TreeIntercptor"/>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>
<context:annotation-config/>
<tx:annotation-driven transaction-manager="transactionManager" />

配置文件如下:
jdbc.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDrive
jdbc.url=jdbc:sqlserver://192.168.1.1:1433/jeecms_2012?characterEncoding=UTF-8
jdbc.username=sa
jdbc.password=xmlrwy808
cpool.minPoolSize=10
cpool.maxPoolSize=20
cpool.maxIdleTime=7200
cpool.maxIdleTimeExcessConnections=1800
cpool.acquireIncrement=10

jar也加过了 就是启动tomcat会提示org.hibernate.util.JDBCExceptionReporter - Connections could not be acquired from the underlying database
启动项目则会报如下错误:
com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.
at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1319)
at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:557)
at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:477)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:525)
at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128)
at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:81)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:142)
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:85)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1354)
at org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:555)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:371)
at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:335)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:105)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy14.getListFromCache(Unknown Source)
at com.jeecms.cms.web.FrontContextInterceptor.preHandle(FrontContextInterceptor.java:35)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:781)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.jeecms.common.web.ProcessTimeFilter.doFilter(ProcessTimeFilter.java:38)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:877)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:594)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1675)
at java.lang.Thread.run(Unknown Source)
求解答 谢谢
两个配置文件在附件里了!

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • iteye_5246 2012-07-26 20:54
    已采纳

    一般这类问题,
    1.连接字符串
    2.配置文件错误,例如:多了个空格
    仔细看完发现,mysql数据库换sqlserver
    sqlserver数据库的 url错了
    仔细看你自己的
    jdbc:sqlserver://192.168.1.1:1433/jeecms_2012?characterEncoding=UTF-8
    正确的是
    jdbc:microsoft:sqlserver://192.168.1.1:1433;DatabaseName=jeecms_2012;

    也就是你配置文件url写错了正确如下:

    jdbc.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDrive
    jdbc.url=jdbc:microsoft:sqlserver://192.168.1.1:1433;DatabaseName=jeecms_2012;
    jdbc.username=sa
    jdbc.password=xmlrwy808
    cpool.minPoolSize=10
    cpool.maxPoolSize=20
    cpool.maxIdleTime=7200
    cpool.maxIdleTimeExcessConnections=1800
    cpool.acquireIncrement=10

    如果还有错误,请留言

    点赞 评论

相关推荐 更多相似问题