javaweb项目将文件上传至数据库中的大小限制

SSH项目将大文件上传至数据库时会出现以下链接已重置:

首先将struts.xml中添加上配置
<!-- 配置文件上传大小 -->
<constant name="struts.multipart.maxSize" value="671088640"></constant> 64M
然后上传大文件出现:

Struts Problem Report

Struts has detected an unhandled exception:

Messages:
  1. Packet for query is too large (24508381 > 10485760). You can change this value on the server by setting the max_allowed_packet' variable.
  2. 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.

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
没有反应
查询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:
  1. The size of BLOB/TEXT data inserted in one transaction is greater than 10% of redo log size. Increase the redo log size using innodb_log_file_size.
  2. Could not execute JDBC batch update
  3. Could not execute JDBC batch update; nested exception is org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update

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即可。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值