MySQL 5.7 in windows, modify the max_allowed_packet variable, mysqlallowedpacket
(1) The following error occurs during SQL Execution: ### 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. $ proxy1_insert (Unknown Source) at org. mybatis. spring. sqlSessionTemplate. insert (SqlSessionTemplate. java: 278) at org.apache.ibatis.binding.MapperMethod.exe cute (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.exe cSQL (ConnectionImpl. java: 2838) at com.mysql.jdbc.PreparedStatement.exe cuteInternal (PreparedStatement. java: 2082) at com.mysql.jdbc.PreparedStatement.exe cute (PreparedStatement. java: 1307) at com.mchange.v2.c31_impl.newproxypreparedstatement.exe cute (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.w.proxy27.exe cute (Unknown Source) at org.apache.ibatis.exe cutor. statement. preparedStatementHandler. update (PreparedStatementHandler. java: 46) at org.apache.ibatis.exe cutor. statement. routingStatementHandler. update (RoutingStatementHandler. java: 74) at org.apache.ibatis.exe cutor. simpleExecutor. doUpdate (SimpleExecutor. java: 50) at org.apache.ibatis.exe cutor. baseExecutor. update (BaseExecutor. java: 117) at org.apache.ibatis.exe cutor. 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. defasqlsqlsession. update (defasqlsqlsession. java: 198) at org. apache. ibatis. session. defaults. defasqlsqlsession. insert (defasqlsqlsession. 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 (2) modify the max_allowed_packet variable in windows. find the file that stores the max_allowed_packet variable, and enter "my. ini ", find this file, I installed to drive C by default," my. ini File Location: 2. open "my. in the ini file, find the location where "max_allowed_packet" is located (4 MB by default) and change it to 16 MB or larger (I have not tried the maximum value, change to the value suitable for your project.) restart the mysql service and log on to the management tool of mysql5.7. Enter show variables like '% max_allowed_packet % '; view the current value of this parameter after modification
If you run the SQL statement that reported the error again, no error will be reported. If you continue to report the error, change the value of the "max_allowed_packet" parameter to a larger value based on the preceding method.
Error cause resolution: MySQL limits the size of data packets received by the server according to the configuration file. Sometimes large inserts and updates are limited by the max_allowed_packet parameter, resulting in failure. You can solve this problem by setting parameters.