`

解决BLOB类型文件大于1MB无法插入数据库的方法

    博客分类:
  • java
阅读更多
如果报:
--- 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.
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics