Connect to MySQL: PacketTooGBigException
Posted by: Arthur Chan
Date: May 08, 2016 04:37PM


I am trying to connect to MySQL database using shared-hosting host on a Ubuntu machine

I got an error message which doesn't make much sense to me:

MySQL JDBC Driver registered

Connection to mysql failed, check output console!

com.mysql.jdbc.PacketTooBigException: Packet for query is too large (3158578 > 1048576). You can change this value on the server by setting the max_allowed_packet' variable.
at com.mysql.jdbc.MysqlIO.readPacket(
at com.mysql.jdbc.MysqlIO.doHandshake(
at com.mysql.jdbc.ConnectionImpl.coreConnect(
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(
at com.mysql.jdbc.ConnectionImpl.createNewIO(
at com.mysql.jdbc.ConnectionImpl.<init>(
at com.mysql.jdbc.JDBC4Connection.<init>(
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
at java.lang.reflect.Constructor.newInstance(
at com.mysql.jdbc.Util.handleNewInstance(
at com.mysql.jdbc.ConnectionImpl.getInstance(
at com.mysql.jdbc.NonRegisteringDriver.connect(
at java.sql.DriverManager.getConnection(
at java.sql.DriverManager.getConnection(
at aboutMySQL.LoadDriver.main(

SELECT @ @global.max_allowed_packet , @ @session.max_allowed_packet
@@global.max_allowed_packet = 268435456
@@session.max_allowed_packet = 268435456

I cannot change the max packet size as it is shared hosting.
Also, the max_allow_packet is way bigger than the packet Java sent.

Options: ReplyQuote

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.