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

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章