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

解决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.

 

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值