重复执行多次查询表功能会报错是为什么呢
() { 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 :连接池中可同时连接的最大的连接数
将初始化数量调小,最大连接数调大试试
祝学习愉快~
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星