hateful
hateful

Reputation: 151

com.mysql.jdbc.PacketTooBigException java

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

Upvotes: 2

Views: 2878

Answers (2)

nyedidikeke
nyedidikeke

Reputation: 7618

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.

Upvotes: 0

Changming Sun
Changming Sun

Reputation: 935

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

Upvotes: 1

Related Questions