c3p0 配置连接MySQL异常:

java.sql.SQLException: Connections could not be acquired from the underlying database!
##
遇到这个问题,可能有2个原因(解决方案):
1.就是jar引入不对,版本可能不对,最主要可能缺少包,以下2个jar包一定要加入;

(1)c3p0-0.9.5.2.jar
(2)mchange-commons-java-0.2.3.4.jar

2.配置文件配置得不对,要注意,name属性的值第一个字母一定要小写,不然真的出不来

<c3p0-config>
  <!-- This app is massive! -->
  <named-config name="mvcapp">
  <property name="user">root</property>
  <property name="password">123456</property>
  <property name="driverClass">com.mysql.jdbc.Driver</property>
  <property name="jdbcUrl">jdbc:mysql://localhost:3306/db_studentinfo</property>


    <property name="acquireIncrement">5</property>
    <property name="initialPoolSize">10</property>
    <property name="minPoolSize">10</property>
    <property name="maxPoolSize">50</property>

    <!-- intergalactoApp adopts a different approach to configuring statement caching -->
    <property name="maxStatements">20</property> 
    <property name="maxStatementsPerConnection">5</property>
  </named-config>
</c3p0-config>
Logo

更多推荐