报错信息摘要如下:
Error querying database. Cause: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1045 > 1024). You can change this value on the server by setting the max_allowed_packet' variable.
### Cause: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1045 > 1024). You can change this value on the server by setting the max_allowed_packet' variable.
产生原因:查询返回的数据量比较大,而允许返回的”max_allowed_packet”太小,导致以上错误。
查看现有参数配置:
解决方案:
在mysql配置文件my.cnf中查找max_allowed_packet参数,有的文件没有,没有的话增加
[mysqld]
max_allowed_packet = 20M
然后重启,mysql,运行程序,可以正常添加数据