Home >Database >Mysql Tutorial >mysql5.5错误: java.sql.SQLException: Packet for query is to

mysql5.5错误: java.sql.SQLException: Packet for query is to

WBOY
WBOYOriginal
2016-06-07 16:25:031031browse

mysql5.5异常: java.sql.SQLException: Packet for query is too large (1055975 1048576). mysql5.5异常: java.sql.SQLException: Packet for query is too large (1055975 1048576). You can change this value on the server by setting the max_allowed

mysql5.5异常: java.sql.SQLException: Packet for query is too large (1055975 > 1048576).

mysql5.5异常: java.sql.SQLException: Packet for query is too large (1055975 > 1048576). You can change this value on the server by setting the max_allowed_packet' variable

解决办法:

1 查阅:

当MySQL客户端或mysqld服务器收到大于max_allowed_packet字节的信息包时,将发出“信息包过大”错误,并关闭连接。对于某些客户端,如果通信信息包过大,在执行查询期间,了能回遇到“丢失与MySQL服务器的连接”错误。


客户端和服务器均有自己的max_allowed_packet变量,因此,如你打算处理大的信息包,必须增加客户端和服务器上的该变量。

2 通过查阅,我知道肯定是自己的爬虫爬得不是网页,因为网页一般都不会超过100kb,所以我就去数据库里看现在正在爬行的链接是什么类型的,最后果不其然发现是是pps文件,大小为5M多,而mysql5.5服务器的默认max_allowed_packet值为1MB。


通过1和2,摆在我们面前的路有两条:

    (1)把mysql服务器的默认max_allowed_packet值设大,我目前的win7系统中,该配置在mysql安装目录下的my-large.ini下。

     (2)不爬取找这样超过默认限制大小的网页。

     

3 w我最后选择了第二条路,因为我目前做的是抓取网页的爬虫,主要就是抓取网页。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn