MySQL Forums
Forum List  »  Connector/JDBC and Java

'Packet for query is too large' exception when connecting
Posted by: Mark Zalavari
Date: October 26, 2012 11:45AM


I have this exception when I create a connection:

Caused by: 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.
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(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(
at com.mysql.jdbc.ConnectionImpl.getInstance(
at com.mysql.jdbc.NonRegisteringDriver.connect(
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection(
at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(

I already set the max_allowed_packet on server side, restarted the server, and I see the change on the mysql console. So the server side seems ok.

Cannot find any solution yet. I checking the driver's source (5.1.21) for clues. The only thing I found for now, is that the default value for this variable on client side is 1M. I suppose it should change only after a successful connection.
Maybe the connection packet is too large for some reason? So maybe it is a server side problem. But what kind of problem can be this?
(server version: 5.5.24)

Thanks for any advice in advance!

Options: ReplyQuote

Written By
'Packet for query is too large' exception when connecting
October 26, 2012 11:45AM

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.