Ramindu De Silva
Ramindu De Silva

Reputation: 3

com.mysql.jdbc.PacketTooBigException: Packet for query is too large even with Packet for query is too large even with max_allowed_packet

I have added the following in the my.cnf as follows

[mysqld]
max_allowed_packet=32M
[mysql]
max_allowed_packet=32M

And I have also added the following to the JDBC query as well

jdbc:mysql://hostname:3306/databaseName?autoReconnect=true&characterEncoding=UTF-8&max_allowed_packet=33554432

But I'm still getting the error mentioned in the subject.

Best Regards, Ramindu.

Upvotes: 1

Views: 5228

Answers (2)

Mitsunori Komatsu
Mitsunori Komatsu

Reputation: 71

I also ran into this issue when I used mysql-connector-java:6.0.6. After moving to 5.1.45, the issue hasn't been reproduced.

Upvotes: 0

Vincent L
Vincent L

Reputation: 739

I had the exact same issue. I changed the setting in my.ini to 512M. When I used the workbench and ran the query "SHOW VARIABLES LIKE 'max_allowed_packet'", it gave me a value of 536870912, but I was still getting the error message:

"com.mysql.cj.jdbc.exceptions.PacketTooBigException: Packet for query is too large (518,358 > 65,535). You can change this value on the server by setting the 'max_allowed_packet' variable.".

I was using version 6.0.6 of the MySQL connector, the latest one available on the Maven repository. After trying a few different versions, it seems like 6.0.3 broke it, so I am now using 6.0.2 and it is working fine!

I know this question has been posted a while ago, but maybe others are still facing this issue.

Upvotes: 1

Related Questions