(一)执行sql遇到的错误如下:
### Cause: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (38708097 > 4194304). You can change this value on the server by setting the max_allowed_packet' variable.
; SQL []; Packet for query is too large (38708097 > 4194304). You can change this value on the server by setting the max_allowed_packet' variable.; nested exception is com.mysql.jdbc.PacketTooBigException: Packet for query is too large (38708097 > 4194304). You can change this value on the server by setting the max_allowed_packet' variable.
at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:108)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
at com.sun.proxy.$Proxy20.insert(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:278)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:57)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
at com.sun.proxy.$Proxy21.insertBatch(Unknown Source)
at com.myJsoup.service.impl.DownloadServiceImpl.insertBatch(DownloadServiceImpl.java:20)
at com.myJsoup.ctrl.DownloadCtrl.addPics(DownloadCtrl.java:50)
at com.myJsoup.ctrl.DownloadCtrlTest.addPics(DownloadCtrlTest.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (38708097 > 4194304). You can change this value on the server by setting the max_allowed_packet' variable.
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3910)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2596)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2776)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2838)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2082)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1307)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.execute(NewProxyPreparedStatement.java:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:59)
at com.sun.proxy.$Proxy27.execute(Unknown Source)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:46)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74)
at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50)
at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117)
at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:63)
at com.sun.proxy.$Proxy25.update(Unknown Source)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:198)
at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:185)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433)
... 32 more
(二)在windows下进行修改max_allowed_packet变量
1.找到存放max_allowed_packet变量所在的文件,在安装目录中输入“my.ini”,找到此文件,我是按照默认安装到C盘的,“my.ini”文件所在位置如下:
 
2.打开“my.ini”文件,找到“max_allowed_packet”所在位置(默认是4M),修改为16M或者更大(本人未尝试最大是多少,修改到适合自己项目需要的值就可以了)
 
重新启动mysql服务
 

 
打开mysql5.7自带的管理工具
 
 
登陆之后,输入 show variables like '%max_allowed_packet%'; 查看当前此参数的值
修改前
 
修改后

再执行你原来报错的sql语句,就不会报错了,如果继续报错,则按照以上方法,将“max_allowed_packet”参数的值再修改的大一点。

错误原因解析:MySQL根据配置文件会限制server接受的数据包大小,有时候大的插入和更新会被max_allowed_packet 参数限制掉,导致失败,通过设置参数可以解决此问题

MySQL 5.7 在windows下修改max_allowed_packet变量的更多相关文章

  1. Windows下修改Android手机的hosts

    Windows下修改Android手机的hosts 1.首先,手机是Root过的. 2.连接手机和电脑, adb shell 进入命令行. 3.获取root用户权限: su -root 4.不知道为何 ...

  2. 在Windows下设置环境变量 运行mysql程序变得更容易

    在Windows下设置环境变量,点开始菜单,右键单击我的电脑--属性--高级--环境变量 可以看到PATH的变量是这样的: C:\WINDOWS;C:\WINDOWS\COMMAND   为了让运行m ...

  3. MemCache服务安装配置及windows下修改端口号

    简述:memcached 开源的分布式缓存数据系统.高性能的NOSQL Linux 一.环境配置与安装 01.编译准备环境 yum install -y gcc make cmake autoconf ...

  4. Windows 下java环境变量的配置(Windows7 ,8,8.1,10)

    Windows 下java环境变量的配置 在“系统”面板的左上角选择“高级系统设置”,在弹出的系统属性中选择”高级“项,然后点击右下角的“环境变量(N)...”,就此进入JAVA环境变量的配置. 如果 ...

  5. Linux系统下修改环境变量PATH路径的三种方法

    这里介绍Linux的知识,比如把/etc/apache/bin目录添加到PATH中有三种方法,看完之后你将学会Linux系统下如何修改环境变量PATH路径,需要的朋友可以参考下 电脑中必不可少的就是操 ...

  6. Mac下修改环境变量

    Mac下修改环境变量 如果使用默认Bash, 首先修改 ~/.bash_profile 文件,添加文件路径,比如: export PATH=~/bin:/usr/local/bin/node:~/Do ...

  7. Linux和Windows下查看环境变量方法对比

    摘自:Linux和Windows下查看环境变量方法对比 一.查看所有环境变量的名称和值 Linux下:export Windows下:set 二.根据名称查该环境变量的值 Linux下:echo $环 ...

  8. Windows 10 修改系统环境变量后,CMD生效,Powershell未生效

    Windows 10 修改系统环境变量后 1.CMD重新打开,新环境变量已经生效: 2.Shift+右键Powershell重新打开,新环境变量没有生效: 3.貌似服务(Apache24)中使用的环境 ...

  9. Windows 下修改 MySQL 编码为 utf8

    问题 Windows 下安装 MySQL 后,默认编码不全utf8. mysql> show variables like '%char%'; +------------------------ ...

随机推荐

  1. hdu3555 Bomb 数位DP入门

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3555 简单的数位DP入门题目 思路和hdu2089基本一样 直接贴代码了,代码里有详细的注释 代码: ...

  2. [刷题]Google Code Jam 2017 - Round1 C Problem A. Ample Syrup

    https://code.google.com/codejam/contest/3274486/dashboard Problem The kitchen at the Infinite House ...

  3. 常用的CI笔记

    1. thinkphp 封装好的$this->success(),就直接实现成功跳转,$this->error(),错误跳转.CI有show_error(),但是却不能直接实现跳转,所以需 ...

  4. .Net程序猿需掌握的知识

    作为一个.Net的技术人员需要掌握的技术,当然,理解这些知识点并不能让你学会.NET开发. 但能够衡量你是否有着走出校门的能力,也算是给自己留一个知识的储备库吧. 共勉! 基础知识: 数据类型 变量 ...

  5. JEESZ-kafka消息服务平台实现

    JEESZ的消息服务平台已经抛弃了之前的ActiveMQ,改用高吞吐量比较大的Kafka分布式消息中间件方案:JEESZ-kafka消息平台使用spring+kafka的集成方案,详情如下:1. 使用 ...

  6. 如何用PHP遍历文件数目 或删除目录下的全部文件?

    先说一下基础知识: 文件位置如下图所示: 1.判断是文件还是目录 var_dump(filetype("./aa/bb/cc.txt")); 输出: string(4) " ...

  7. Hibernate createQuery调用joincolumn

    1. Beans a. Version Bean package locationService.beans; import java.sql.Timestamp; import java.util. ...

  8. 在Excel上写程序(ExcelEx)

    首先要说明的是:Ctrl+D,是执行框选的的扩展函数+号,一个单元格里多个函数用+号分隔*号,相当于链式操作(没法子,公式里不能写"."号) 虽还有很大的局限性,至少很多小程序和数 ...

  9. .net实现多重继承问题(virtual)

    C#中是没有类的多重继承这个概念.要使用多重继承必须要通过接口Interface来完成, 一.接口类 interface  getTable{      DataTable Getdatatable( ...

  10. SonarQube+Jenkins,搭建持续交付平台

    前言 Kurt Bittner曾说过,如果敏捷仅仅只是开始,那持续交付就是头条! "If Agile Was the Opening Act, Continuous Delivery is ...