SSM整合遇到的问题
问题
今天在整合SSM框架时,出现了以下警告报错:
1 | 警告: com[email protected]98a2c7f -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (2). Last acquisition attempt exception: |
很明显,这是使用c3p0连接池的问题,经过我的分析后明白了原因。
由于之前使用的是默认的jdbc连接,所以db.properties配置文件是这样写的:
1 | driver=com.mysql.jdbc.Driver |
但这里使用了c3p0,使用以上配置后username这一项可能有了冲突,因为改了这一项后便可正确执行数据查询,我后面去查看了一下db.properties的正确写法,总结如下:
使用前缀,如jdbc、jb等,这个限制不清楚,后缀一个也可以随便写
1
2
3
4com.mysql.jdbc.Driver =
jdbc:mysql://localhost:3306/mybatis?useSSL=true&useUnicode=true&characterEncoding=UTF-8 =
root =
111111 =我们使用对应连接池的变量名来配置
1
2
3
4driverClass=com.mysql.jdbc.Driver
jdbcUrl=jdbc:mysql://localhost:3306/mybatis?useSSL=true&useUnicode=true&characterEncoding=UTF-8
user=root
password=111111
总的来说,我们可以使用第一种前缀写法,可以用于不同的连接池。
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 哀殿firstの空间!
评论