1. 程式人生 > >javaweb專案將檔案上傳至資料庫中的大小限制

javaweb專案將檔案上傳至資料庫中的大小限制

首先將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即可。