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

出处:http://aaron81939097.iteye.com/blog/1144642

原配置:

Java代码  

  1. <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
  2. <!-- 指定连接数据库的JDBC驱动 -->
  3. <property name="driverClass">
  4. <value>com.mysql.jdbc.Driver</value>
  5. </property>
  6. <!-- 连接数据库所用的URL -->
  7. <property name="jdbcUrl">
  8. <value>jdbc:mysql://localhost:3306/activiti?autoReconnect=true
  9. </value>
  10. </property>
  11. <!-- 连接数据库的username -->
  12. <property name="user">
  13. <value>sa </value>
  14. </property>
  15. <!-- 连接数据库的密码 -->
  16. <property name="password">
  17. <value></value>
  18. </property>
  19. <!-- 设置数据库连接池的最大连接数 -->
  20. <property name="maxPoolSize">
  21. <value>20</value>
  22. </property>
  23. <!-- 设置数据库连接池的最小连接数 -->
  24. <property name="minPoolSize">
  25. <value>2</value>
  26. </property>
  27. <!-- 设置数据库连接池的初始化连接数 -->
  28. <property name="initialPoolSize">
  29. <value>2</value>
  30. </property>
  31. <!-- 设置数据库连接池的连接的最大空暇时间,单位为秒 -->
  32. <property name="maxIdleTime">
  33. <value>20</value>
  34. </property>
  35. </bean>

配置数据都无问题的情况下,发现下面情况会产生错误:

情况1:value元素值之间出现空格(人为加入)

Java代码  

  1. <property name="driverClass">
  2. <value>com.mysql.jdbc.Driver </value>
  3. </property>

情况2:value结束标签换行(当value值比較长时,Ctrl+Shift+F的时就会换行)

Java代码  

  1. <property name="driverClass">
  2. <value>com.mysql.jdbc.Driver
  3. </value>
  4. </property>

今天产生错误属于情况2,因此建议配置datasource使用以下格式配置:

Java代码  

  1. <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
  2. <!-- 指定连接数据库的JDBC驱动 -->
  3. <property name="driverClass" value="com.mysql.jdbc.Driver">
  4. </property>
  5. <!-- 连接数据库所用的URL -->
  6. <property name="jdbcUrl"
  7. value="jdbc:mysql://localhost:3306/activiti?autoReconnect=true">
  8. </property>
  9. <!-- 连接数据库的username -->
  10. <property name="user" value="sa">
  11. </property>
  12. <!-- 连接数据库的密码 -->
  13. <property name="password" value="">
  14. </property>
  15. <!-- 设置数据库连接池的最大连接数 -->
  16. <property name="maxPoolSize" value="20">
  17. </property>
  18. <!-- 设置数据库连接池的最小连接数 -->
  19. <property name="minPoolSize" value="2">
  20. </property>
  21. <!-- 设置数据库连接池的初始化连接数 -->
  22. <property name="initialPoolSize" value="2">
  23. </property>
  24. <!-- 设置数据库连接池的连接的最大空暇时间,单位为秒 -->
  25. <property name="maxIdleTime" value="20">
  26. </property>
  27. </bean>
时间: 2024-10-11 04:18:45

A ResourcePool could not acquire a resource from its primary factory or source的相关文章

数据库连接错误:CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.

学习Spring整合Hibernate的知识,新建一个工程,代码结构如下: 按如下步骤整合: 代码如下: hibernate.cfg.xml: 1 <?xml version="1.0" encoding="UTF-8"?> 2 <!DOCTYPE hibernate-configuration PUBLIC 3 "-//Hibernate/Hibernate Configuration DTD 3.0//EN" 4 "

c3p0 空指针异常 com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.

[email protected]5 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception:

连接mysql提示com.mchange.v2.resourcepool.BasicResourcePool

连接mysql提示 com[email protected]6ff9129c -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition

java.sql.SQLException: Connections could not be acquired from the underlying database!

警告: [email protected]72 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30).java.sql.SQLException: Connectio

C3P0数据库连接池的相关bug解决

数据库连接池的几个常见bug: 1.警告: com[email protected]76c7022e -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks! 十月 01, 2016 6:28:24 下午 com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector run 80%以上原因是数据连接配置或数据库等类似问题.

Spring+Hibernate小异常

org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Cannot open connection at org.springframework.orm.hibernate3.Hiberna

servlet 项目 ,,启动没问题,,但是,一请求也面就报错误。。。。求解决。。。。。。。。。。。。。各种百度,都没解决了啊。。。。。急急急急急急急急急急急急急急急急急急

信息: Server startup in 1674 mslog4j:WARN No appenders could be found for logger (com.mchange.v2.log.MLog).log4j:WARN Please initialize the log4j system properly.2015-6-4 23:52:40 org.apache.catalina.core.StandardWrapperValve invoke严重: Servlet.service(

java 连接mariadb 无法获取数据源的问题,在ubuntu上部署的时候(原创)

问题: 连接数据库时报错: log4j:WARN No appenders could be found for logger (com.mchange.v2.log.MLog).log4j:WARN Please initialize the log4j system properly.log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.java.lang.RuntimeExcep

Hibernate异常--数据库所在服务器关闭引起的异常

春节前要回家去的日子,一切准备就绪,项目初期版本也已经基本上完成.本来想着可以愉快的回家了,结果在给导师演示的时候报出一堆的异常,之前测试的时候很正常,关键时候就报了一堆bug,你能理解我当时的心情是多么的复杂吗?在此记录下这个异常,以便以后再次遇到的时候可以立刻意识到是哪里的问题. 异常的信息如下: 由于异常信息比较多,我在上面进行解释并阐述一下我找到问题根源的思路: 1. 看异常的开头部分显示的是struts异常,这时候不能说一定就是struts的问题,因为往往异常的抛出是这样的一个过程,比