SSH项目将大文件上传至数据库时会出现以下链接已重置:
首先将struts.xml中添加上配置
<!-- 配置文件上传大小 -->
<constant name="struts.multipart.maxSize" value="671088640"></constant> 64M
<constant name="struts.multipart.maxSize" value="671088640"></constant> 64M
然后上传大文件出现:
Struts Problem Report
Struts has detected an unhandled exception:
Messages: |
|
Stacktraces
org.springframework.jdbc.UncategorizedSQLException: Hibernate flushing: Could not execute JDBC batch update; uncategorized SQLException for SQL [insert into file (file, id) values (?, ?)]; SQL state [S1000]; error code [0]; Packet for query is too large (24508381 > 10485760). You can change this value on the server by setting the max_allowed_packet' variable.; nested exception is java.sql.BatchUpdateException: Packet for query is too large (24508381 > 10485760). You can change this value on the server by setting the max_allowed_packet' variable.
但是还有文件10M的限制
继续设置
MySQL安装目录下的my.ini文件,添加
max_allowed_packet=64M
[mysqld]
character-set-server=utf8
default-storage-engine=INNODB
max_allowed_packet=64M
character-set-server=utf8
default-storage-engine=INNODB
max_allowed_packet=64M
没有反应
查询MySQL启动服务的启动配置参数,
"C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqld.exe" --defaults-file="C:\ProgramData\MySQL\MySQL Server 5.6\my.ini" MySQL56
发现其会加载
C:\ProgramData\MySQL\MySQL Server 5.6\my.ini,更改其中max_allowed_packet=64M。
更改后发现会出现以下错误:
Messages: |
|
Stacktraces
org.springframework.dao.InvalidDataAccessResourceUsageException: Could not execute JDBC batch update; nested exception is org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update
再在C:\ProgramData\MySQL\MySQL Server 5.6\my.ini,更改其中
innodb_log_file_size=48M为640M即可。