com.mysql.jdbc.PacketTooBigException solution

An exception is thrown when the discovery program is processed:
org.apache.ibatis.exceptions.PersistenceException: \n### Error updating database.  Cause: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1049134 > 1048576). You can change this value on the server by setting the max_allowed_packet' variable.\n


The investigation found that the max_allowed_packet parameter is too small when performing batch operations.
show VARIABLES like '%max_allowed_packet%';  


Use the command to set max_allowed_packet to 10M.
set global max_allowed_packet = 10*1024*1024 


Re-login query (must log out and re-login), the value has changed. Execute the program, the problem is solved.

Note: This method only takes effect when this setting is valid, and the setting is invalid after restarting mysql. For permanent effect, you can modify mysql.cnf (my.ini under windows), and modify it in the [mysqld] section or the server configuration section of mysql.
max_allowed_packet = 20K

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326392096&siteId=291194637