我最近遇到一个问题,mysql-connector抛出一个Exception,这意味着max_allowed_packet = -1,但是当我查询我的数据库时,它显示如下: max_allowed_packet = 67108864
错误详情如下:
引起:com.mysql.jdbc.PacketTooBigException:查询包太大(77> -1)。您可以更改此值 服务器通过设置' max_allowed_packet'变量。在 com.mysql.jdbc.MysqlIO。的 readPacket(MysqlIO.java:612) 〜[mysql-connector-java-5.1.13.jar:na] at com.mysql.jdbc.MysqlIO.getResultSet(MysqlIO.java:415) 〜[mysql-connector-java-5.1.13.jar:na] at com.mysql.jdbc.MysqlIO.readResultsForQueryOrUpdate(MysqlIO.java:2581) 〜[mysql-connector-java-5.1.13.jar:na] at com.mysql.jdbc.MysqlIO.readAllResults(MysqlIO.java:1757) 〜[mysql-connector-java-5.1.13.jar:na] at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2171) 〜[mysql-connector-java-5.1.13.jar:na] at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2568) 〜[mysql-connector-java-5.1.13.jar:na] at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2113) 〜[mysql-connector-java-5.1.13.jar:na] at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1364) 〜[mysql-connector-java-5.1.13.jar:na] at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:56) 〜[mybatis-3.2.5.jar:3.2.5] at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:70) 〜[mybatis-3.2.5.jar:3.2.5] at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:57) 〜[mybatis-3.2.5.jar:3.2.5] at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:259) 〜[mybatis-3.2.5.jar:3.2.5] at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:132) 〜[mybatis-3.2.5.jar:3.2.5] at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:105) 〜[mybatis-3.2.5.jar:3.2.5] at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:81) 〜[mybatis-3.2.5.jar:3.2.5] at sun.reflect.GeneratedMethodAccessor162.invoke(Unknown Source)〜[na:na] 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 〜[na:1.6.0_43] at java.lang.reflect.Method.invoke(Method.java:597) 〜[na:1.6.0_43] at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:46) 〜[mybatis-3.2.5.jar:3.2.5] at com.baidu.bainuo.bppoi.interceptor.MybatisInterceptor.intercept(MybatisInterceptor.java:67) 〜[bp-poi-service-1.0.20-SNAPSHOT.jar:na] at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:57) 〜[mybatis-3.2.5.jar:3.2.5]在com.sun.proxy。$ Proxy34.query(未知 来源)〜[na:na] at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:104) 〜[mybatis-3.2.5.jar:3.2.5] at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:98) 〜[mybatis-3.2.5.jar:3.2.5] at sun.reflect.GeneratedMethodAccessor161.invoke(Unknown Source)〜[na:na] 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 〜[na:1.6.0_43] at java.lang.reflect.Method.invoke(Method.java:597) 〜[na:1.6.0_43] at org.mybatis.spring.SqlSessionTemplate $ SqlSessionInterceptor.invoke(SqlSessionTemplate.java:358) 〜[mybatis-spring-1.2.2.jar:1.2.2] ...省略了54个常见框架
答案 0 :(得分:0)
考虑更正您的jdbc代码以符合您的要求。 MySQL 5.6服务器变量表示最小值为1024。