我在做JDBC连接池的时候,总是报超时错误
>
java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.
这个就是连接超时的问题,我查了之后,发现好多人只是驱动jar包版本的问题,根本解决不了我的问题
这里是引用
https://blog.csdn.net/Akanarika520/article/details/82688351?utm_medium=distribute.pc_relevant_t0.none-task-blog-searchFromBaidu-1.nonecase&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-searchFromBaidu-1.nonecase
这个博客的评论解决了我的问题,
<property name="jdbcUrl">jdbc:mysql://localhost:3306/jdbc1?useSSL=false&serverTimezone=GMT</property>
其实也只是url的设置问题,我在
https://blog.csdn.net/weixin_44955540/article/details/108539760
这个文章里写过的我的JDBC连接问题,两个都一样,我当时也修改过这个格式,没起作用,我也就没管这个问题,
后来才发现,
这两个写法不同
在这里插入代码片
jdbc:mysql://localhost:3306/jdbc1?useSSL=false&serverTimezone=UTC
正确的写法
jdbc:mysql://localhost:3306/db?serverTimezone=UTC&useSSL=false
我当时JDBC连接时时这样写的,但是区别是,我的是在代码中写的不影响“&”这个,但是JDBC连接池是在XML文件中,无法识别“&”,所以一直报错。