重复执行多次查询表功能会报错是为什么呢
() {
Properties properties=Properties()String propertyFile = SelectCommand..getResource().getPath(){
propertyFile=URLDecoder().(propertyFile)properties.load(FileInputStream(propertyFile))DataSource dataSource= DruidDataSourceFactory.(properties)QueryRunner qr=QueryRunner(dataSource)List<News> list=qr.query(BeanListHandler<>(News.))(list.size()==){
System..println()}{
(News emp:list){
System..println(emp)}
}
} (Exception e) {
System..println()e.printStackTrace()}
}十一月 18, 2021 10:39:33 下午 com.alibaba.druid.pool.DruidDataSource error
严重: init datasource error, url: jdbc:mysql://localhost:3306/imooc?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
java.sql.SQLNonTransientConnectionException: Data source rejected establishment of connection, message from server: "Too many connections"

十一月 18, 2021 10:39:46 下午 com.alibaba.druid.pool.DruidDataSource error
严重: create connection SQLException, url: jdbc:mysql://localhost:3306/imooc?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true, errorCode 1040, state 08004
java.sql.SQLNonTransientConnectionException: Data source rejected establishment of connection, message from server: "Too many connections"

正在回答
同学你好,同学修改下配置文件中的initialSize 和maxActive 试试
initialSize :连接池启动时创建的初始化连接数量
maxActive :连接池中可同时连接的最大的连接数
将初始化数量调小,最大连接数调大试试
祝学习愉快~
- 参与学习 人
- 提交作业 8788 份
- 解答问题 9886 个
综合就业常年第一,编程排行常年霸榜,北上广深月薪过万! 不需要基础,无需脱产即可学习,只要你有梦想,想高薪! 全新升级:技术栈升级(包含VUE3.0,ES6,Git)+项目升级(前后端联调与功能升级)
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星