【求助】mysql报错Packet for query is too large

Sql: select accountId from account_role where accountId = ? and roleId = 9
Sql: SELECT * FROM ( SELECT stock.LBID, stock.RK_time, stock.changjia, stock.pinzhong, stock.guige, stock.caizhi, stock.bianhao, stock.zhongliang, stock.cangku, stock.factoryAllName, stock.weizhi, stock.beizhu, stock.liubanjieru, stock.LB_Type, stock.Type, stock.ZaGe, stock.LB_time, stock.TG_time, stock.count_down, stock.yewubeizhu, stock.CKCG_time, stock.stockOutTime, stock.saleTime, stock.cancelTime, stock.cancelUserName, stock.lock_time, stock.Update_time, stock.Auto_LB_Cancel, stock.liubanjieru2, stock.LB_Type2, stock.yewuliubanxinxi, stock.sqlUpTime, stock.bill_id, stock.bill_sort, stock.sum_price, stock.typeActive, stock.dismantlingAutoNo, bill.serialNumber, bill.buyer, bill.salesman, bill.supplyCompany, bill.purchaseCompany, bill.dateNow, bill.count_sum, bill.zhongliang_sum, bill.sum_price_sum, bill.remarksFrist, bill.remarks, bill.typeActive as billTypeActive, bill.pickUpRemark, bill.pickUppurchaseCompany, bill.pickUpbuyer, bill.pickUpCarNo, bill.myCompany, bill.agent, bill.machiningCompany, bill.processingRequirements, bill.documentMaker, bill.freight, bill.isDelete, bill.weightMachiningRealitySum, bill.weightMachiningRealityLoss, bill.dismantlingAuto FROM bill, stock WHERE bill.serialNumber = stock.bill_id AND isDelete <> '-1' ) aa WHERE aa.saleTime BETWEEN ? AND  ? ORDER BY `saleTime` DESC
14052 [qtp205962452-29] ERROR com.jfinal.core.ActionHandler  [   ] – /statistics/getData?dateStart=2019-03-01&dateEnd=2019-03-31&_=1551499534129
com.jfinal.plugin.activerecord.ActiveRecordException: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1352 > 1024). You can change this value on the server by setting the max_allowed_packet' variable.
	at com.jfinal.plugin.activerecord.Model.find(Model.java:662)
	at com.steel.statistics.StatisticsController.getData(StatisticsController.java:56)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:73)
	at com.steel.admin.auth.AdminAuthInterceptor.intercept(AdminAuthInterceptor.java:50)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:67)
	at com.steel.login.LoginSessionInterceptor.intercept(LoginSessionInterceptor.java:50)
	at com.jfinal.aop.Invocation.invoke(Invocation.java:67)
	at com.jfinal.core.ActionHandler.handle(ActionHandler.java:78)
	at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:73)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1307)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:453)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:560)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1072)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:382)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1006)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
	at org.eclipse.jetty.server.Server.handle(Server.java:365)
	at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:485)
	at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:926)
	at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:988)
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:635)
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
	at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
	at java.lang.Thread.run(Unknown Source)
Caused by: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1352 > 1024). You can change this value on the server by setting the max_allowed_packet' variable.
	at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3778)
	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2471)
	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2651)
	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2683)
	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2144)
	at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2310)
	at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeQuery(DruidPooledPreparedStatement.java:228)
	at com.jfinal.plugin.activerecord.Model.find(Model.java:643)
	at com.jfinal.plugin.activerecord.Model.find(Model.java:660)
	... 35 more

我已近找过其他办法,扩写max_allowed_packet也不行!!!

评论区

JFinal

2019-03-02 12:19

异常信息中已经提供了具体的解决办法:
Caused by: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1352 > 1024). You can change this value on the server by setting the max_allowed_packet' variable.

配置 mysql 服务端的 max_allowed_packet 变量

fmpoffice

2019-03-02 13:10

@JFinal 谢谢老大回复,我已经改过1G了,还是不行,过段时间报错!现在优化了sql,把没用到的字段不进行查询!看看怎么样

JFinal

2019-03-02 16:09

@fmpoffice 光配置是不行的,你还得去查看配置到底生效没有,通过现在的步骤查看:
1:使用 mysql -u root -p 命令登录到 mysql 控制台
2:使用 show variables like '%max_allowed_packet%'; 命令查看 max_allowed_packet 的值到底是多少

默认值应该是:4194304,你的只有 1024,明显被人动过

fmpoffice

2019-03-04 16:40

@JFinal 谢谢指点,估计应该是我之前设置错误了

热门反馈

扫码入社