Druid报错
Sep 11, 2024 11:16:03 AM com.alibaba.druid.pool.DruidDataSource error
SEVERE: init datasource error, url: "jdbc:mysql://x.x.x.x:xxxx/test01?useSSL=false&serverTimezone=UTC"
java.sql.SQLException: connect error, url "jdbc:mysql://x.x.x.x:xxxx/test01?useSSL=false&serverTimezone=UTC", driverClass com.mysql.cj.jdbc.Driver
at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1640)
at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:874)
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1246)
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1242)
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:89)
at local.content.druid.DruidDemo.main(DruidDemo.java:24)
druid.properties文件配置
driverClassName=com.mysql.cj.jdbc.Driver
url="jdbc:mysql://xxxx:3306/test01?useSSL=false&serverTimezone=UTC"
username="test_rw"
password="1234556"
#xxx
initialSize=5
#xxx
maxActive=10
#xxx
maxWait=3000
搜了许多情况,有人是username写成了user,有人是jdbc:mysql写成了http:mysql;
我这个是因为url,username,password加了双引号导致的;
双引号去掉后即成功执行;