1、c3p0配置文件必须为c3p0-config.xml
2、该配置文件必须放在src目录下
配置文件:
<?xml version="1.0" encoding="UTF-8"?>
<c3p0-config>
<named-config name="mysql">
//必须要的配置
<property name="user">root</property>
<property name="password">123456</property>
<property name="driverClass">com.mysql.jdbc.Driver</property>
<property name="jdbcUrl">jdbc:mysql://127.0.0.1:3306/mvctest</property>//mvctest为实际数据库的名称
//相关配置,还可以有更多的配置属性,可查看官方文档
<property name="acquireIncrement">5</property>
<property name="initialPoolSize">10</property>
<property name="minPoolSize">10</property>
<property name="maxPoolSize">15</property>
<!-- intergalactoApp adopts a different approach to configuring statement
caching -->
<property name="maxStatements">20</property>
<property name="maxStatementsPerConnection">5</property>
</named-config>
</c3p0-config>
我在使用时将配置文件的名称写错了导致一直报错,