Packet for query is too large
Posted by: Sebastian Klute
Date: December 17, 2013 02:27AM

Hello,

I hope you can help me.

I´m trying to use the MySQL-Database of my Webspace via Java. To do that I need to connect to the Webspace using a ssh-tunnel, I use JSch to do that an the Connections works.

To connect to the database I use Connector/J 5.1.27. Here is the code I use in Java:

******************************************
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/db553?maxAllowedPacket=104857","user","pw");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM Test");
*******************************************

I get the folowing 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.
at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:613)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1088)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2493)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2526)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2311)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:834)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
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(Util.java:411)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:416)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:347)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at dbtest.main(dbtest.java:61)
**********************************************

I only have a small Webspace, so I can not Change the "max_allowed_packet'" but with "maxAllowedPacket=104857" the error should not appear, or am I wrong? What is my mistake? The Error Occurs directly after the line:

Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/db553?maxAllowedPacket=104857","user","pw");


So the System is only opening the Connection.

Any Ideas?

Kind Regards,
Sebix

Options: ReplyQuote


Subject
Written By
Posted
Packet for query is too large
December 17, 2013 02:27AM


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.