一个小问题 关于 com.mysql.jdbc.PacketTooBigException: Packet for query is too large
这个错本身就是应为传输的数据大于mysql的max_allowed_packet参数默认值造成的;
之前遇到这个问题,一直是改max_allowed_packet的值 ,做项目遇到这个错误改了好几次,从1M改到10M,10M改到50M,50M又不够了;没有考虑到增量数据的问题,有的数据是一直增长的。
所以解决这个问题的根本,是需要在程序中,做分批次插入;
//data 为需要入库的数据,持续增长中目前3万多行,需要切分为几个list
LinkedList<LinkedHashMap<String,Object>> data=new LinkedList<LinkedHashMap<String,Object>>();
.....
//收集数据 data.add(xxxx)
......
//入库
HashMap<String,Object> map= new HashMap<>();
map.put("table_name", "tbl_consistency_check");
consCheckDao.truncateTable(map); //分批次入库(一批3000行)
Integer size=data.size();
Integer batches_size=3000;
Integer num=size/batches_size;
for(int i=0;i<num;i++) {
List<LinkedHashMap<String, Object>> tmp= data.subList(0, batches_size);
map.put("data", tmp);
consCheckDao.insertConCheckTable(map);
data.subList(0, batches_size).clear();
} List<LinkedHashMap<String, Object>> tmp_2= data.subList(0, data.size());
map.put("data", tmp_2);
consCheckDao.insertConCheckTable(map);
一个小问题 关于 com.mysql.jdbc.PacketTooBigException: Packet for query is too large的更多相关文章
- com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1169 > 1024)
### Cause: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1169 > 1024). You ...
- nested exception is com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1044 > 1024
HTTP Status 500 - type Exception report message description The server encountered an internal error ...
- Cause: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (16944839 > 16777216). You can change this value on the server by setting the max_allowed_packet' variable.
今天发现task微服务的error日志报如下错误: Cause: com.mysql.jdbc.PacketTooBigException: Packet for query is too large ...
- MySQL异常:com.mysql.jdbc.PacketTooBigException: Packet for query is too large
### Cause: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1169 > 1024). You ...
- nested exception is com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1109 > 1024
MySQL的一个系统参数:max_allowed_packet >mysql -u root -p //root登录 1. 查看系统参数:show VARIABLES like '%max_al ...
- com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1680 > 1024). You can change this value on the server by setting the max_allowed_packet' variable.
这个错误是由于mysql的一个系统参数max_allowed_packet设置的值过小引起的 解决这个错误的方法就是修改这个参数的值, linux系统中我们在etc目录下找到my.cnf这个文件,打开 ...
- 解决com.mysql.jdbc.PacketTooBigException: Packet for query is too large
在做查询数据库操作时,报了以上错误,还有out of memery heap hacp ,原因是MySQL的max_allowed_packet设置过小引起的,我一开始设置的是1M,后来改为了20M ...
- 【问题解决:Mysql操作容量限制问题】Error updating database. Cause: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1082 > 1024)
在做查询数据库操作时,报了以上错误,还有out of memery heap hacp ,原因是mysql的max_allowed_packet设置过小引起的,我一开始设置的是1M,后来改为了20M ...
- Linux服务器上日志报com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1783 > 1024). You can change this value on the server by setting the max_allowed_packet' variable.
在做查询数据库操作时,报了以上错误,还有out of memery heap hacp ,原因是MySQL的max_allowed_packet设置过小引起的,我一开始设置的是1M,后来改为了20M ...
随机推荐
- Java代码中对IP进行白名单验证
来自:https://www.cnblogs.com/shinubi/p/6723003.html public class ipUtil { // IP的正则,这个正则不能验证第一组数字为0的情况 ...
- vscode java
https://devblogs.microsoft.com/visualstudio/announcing-visual-studio-code-java-installer/ public cla ...
- Java连载9-数据类型&字符编码
一.数据类型注意:(1)计算机最初只支持英文,最先出现的字符编码是:ASII码例如:‘a'对应97,对应01100001(2)编码和解码的时候采用同一套字典/对照表,不会出现乱码.否则会出现乱码.二. ...
- Python基础 — 面向对象编程基础
目录 1. 面向对象编程基础 2. 定义类和创建对象 3. init() 方法 4. 魔法方法 5. 访问可见性问题 5. 练习 1. 面向对象编程基础 把一组数据结构和处理它们的方法组成对象(obj ...
- ROS融合IMU笔记
ROS官网有一个叫robot_pose_ekf的包,是专门处理传感器融合的包,具体介绍:http://wiki.ros.org/robot_pose_ekf 其中主要功能是订阅主题包括odom(里程计 ...
- idea类存在找不到解决办法
清除idea缓存,
- UVA 583 分解质因数
Webster defines prime as:prime (prim) n. [ME, fr. MF, fem. of prin first, L primus; akin to L prior] ...
- Redis(九)高可用专栏之Sentinel模式
本文讲述Redis高可用方案中的哨兵模式--Sentinel,RedisClient中的Jedis如何使用以及使用原理. Redis主从复制 Redis Sentinel模式 Jedis中的Senti ...
- 【Elasticsearch】【WEB】java web服务连接es elasticsearch始终报错,无法正常连接使用的错误解决历程
前情提要: web服务往华为云上迁移 ================内网的好环境,相关配置=================== 1.web服务关于ES的集群配置如下: elasticAddress ...
- C# - Winform - DevExpress - GridControl 任意条件控制Row背景色。
private void gvSendConfirm_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCusto ...