使用C3P0时出现java.sql.SQLException: No suitable driver的几种解决办法

1、首先要检查配置文件是否有问题:连接URL格式出现了问题(Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/XX","root","XXXX")

<?xml version="1.0" encoding="UTF-8"?>

<c3p0-config>
    <default-config>
        <property name="driverClass">com.mysql.jdbc.Driver</property>
        <property name="jdbcUrl">jdbc:mysql://localhost:3306/test02?useUnicode=true&amp;characterEncoding=utf8&amp;useSSL=true</property>
        <property name="user">root</property>
        <property name="password">123123</property>

        <property name="acquireIncrement">5</property>
        <property name="initialPoolSize">10</property>
        <property name="minPoolSize">5</property>
        <property name="maxPoolSize">20</property>
    </default-config>
</c3p0-config>

 

2 、检查配置文件c3p0-config.xml的位置

Java项目在/src目录下

web项目在/src/main/resources目录下

Maven项目在/src/main/resources目录下

 

3、c3p0的配置文件名必须是 c3p0-config.xml

 

4 、检查Buildpath中没有加入合适的mysql_jdbc驱动
项目名上点击右键—>Build Path

posted @ 2021-06-30 01:48  poscana  阅读(1050)  评论(0编辑  收藏  举报