com.mysql.jdbc.PacketTooBigException java [英] com.mysql.jdbc.PacketTooBigException java

查看:115
本文介绍了com.mysql.jdbc.PacketTooBigException java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试连接数据库时出现此问题。更改变量的值,但此错误仍然存​​在

I'm having this problem when trying to connect to my database. Change the value of the variable but still this error persists

值mysql

@@max_allowed_packet
16777216

Java代码

Properties connProps = new Properties();
connProps.put("user", Config.DB_USER);
connProps.put("password", Config.DB_PASS);
this._conn = DriverManager.getConnection("jdbc:" + Config.DB_DBMS + "://" + Config.DB_HOST + ":"
  + Config.DB_PORT + "/" + Config.DB_NAME, connProps);

错误:

com.mysql.jdbc.PacketTooBigException: Packet for query is too large (4739923 > 1048576). You can change this value on the server by setting the max_allowed_packet' variable.

修改我的 my.cnf 文件服务器

推荐答案

jdbc客户端也有maxAllowedPacket设置。

The jdbc client, also has a "maxAllowedPacket" setting.

你可以设置你的jdbc网址:
jdbc:mysql://192.168.15.1/dbname?useUnicode = true& characterEncoding = UTF-8& maxAllowedPacket = 16777216

You may set your jdbc url like: jdbc:mysql://192.168.15.1/dbname?useUnicode=true&characterEncoding=UTF-8&maxAllowedPacket=16777216

这篇关于com.mysql.jdbc.PacketTooBigException java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆