运行blob测试程序,数据有点大,32M,结果报出了下面的异常信息:
com.mysql.jdbc.PacketTooBigException: Packet for query is too large (37748784 > 1048576). You can change this value on the server by setting the max_allowed_packet' variable.
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2691)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1612)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3283)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1332)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1604)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1519)
解决方法,在my.ini里的[mysqld]增加如下部分
[mysqld]
max_allowed_packet=64M
注意,在[client]和[mysql]部分增加无效,那个是客户端读取的参数。
注意:需要重新启动mysql服务!