解决BLOB类型文件大于1MB无法插入数据库的方法
如果报:
--- Cause: com.mysql.jdbc.PacketTooBigException: Packet for query is too large (1052876 > 1048576). You can change this value on the server by setting the max_allowed_packet' variable.
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeUpdate(GeneralStatement.java:91)
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(SqlMapExecutorDelegate.java:447)
就需要修改(参见http://dev.mysql.com/doc/refman/5.0/en/packet-too-large.html)
for example, if you are working with big BLOB columns). For example, to set the variable to 16MB, start the server like this:
The server's default max_allowed_packet value is 1MB.
You can increase this if the server needs to handle big queries
(for example, if you are working with big BLOB columns).
For example, to set the variable to 16MB, start the server like this:
1。启动mysql的时候加命令:
shell> mysqld --max_allowed_packet=16M
2。或在my.ini中加入:
[mysqld]
max_allowed_packet=16M
注意这里是在mysqld下添加这句话的。官方也提倡这种办法。
It is safe to increase the value of this variable because the extra memory
is allocated only when needed. For example, mysqld allocates more memory only
when you issue a long query or when mysqld must return a large result row.
The small default value of the variable is a precaution to catch incorrect
packets between the client and server and also to ensure that you do not run out
of memory by using large packets accidentally.
本文介绍了解决MySQL数据库中超过1MB大小的BLOB文件无法插入的问题。通过调整max_allowed_packet参数来允许更大的文件插入,提供了两种设置方法:启动MySQL时直接指定或在my.ini文件中配置。
4万+

被折叠的 条评论
为什么被折叠?



