热门关键字:  博客  博客入门  博客创建  新浪博客  css
当前位置 :| 首页>博客制作>后台制作>

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

来源:学博客收集整理 作者:佚名 时间:2008-11-21 点击:
如果报:
--- 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.

最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册