2

I'm having this problem when trying to connect to my database. Change the value of the variable but still this error persists

Value mysql

@@max_allowed_packet
16777216

Java Code

Properties connProps = new Properties();
connProps.put("user", Config.DB_USER);
connProps.put("password", Config.DB_PASS);
this._conn = DriverManager.getConnection("jdbc:" + Config.DB_DBMS + "://" + Config.DB_HOST + ":"
  + Config.DB_PORT + "/" + Config.DB_NAME, connProps);

Error :

com.mysql.jdbc.PacketTooBigException: Packet for query is too large (4739923 > 1048576). You can change this value on the server by setting the max_allowed_packet' variable.

Modify the my.cnf file on my server

2
  • Did you restart MySQL on the server after updating the configuration file? Commented Apr 6, 2016 at 19:01
  • If, in fact reset mysql, verify the value in the database and the new value appears, but from my jar receipt that error @GordThompson Commented Apr 6, 2016 at 19:12

2 Answers 2

1

The jdbc client, also has a "maxAllowedPacket" setting.

You may set your jdbc url like: jdbc:mysql://192.168.15.1/dbname?useUnicode=true&characterEncoding=UTF-8&maxAllowedPacket=16777216

Sign up to request clarification or add additional context in comments.

Comments

0

Had the same error, trying to connect to a MySQL database using DataGrip 2016.1 (from JetBrains).

Error: Packet for query is to large (5526600 > 1048576).

Troubleshooting further, I've realised that my records entry were wrong; the database password was not correct.

Upon rectification using the correct database password, I no longer encountered the error and was able to connect successfully.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.