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

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

问题描述

我有一个大问题!
当我这样做:

  String query =SELECT * FROM utente WHERE confermato = 1 and Username =' + username 
+'AND Password ='+ password +';

Class.forName(com.mysql.jdbc.Driver)。newInstance();
Connection con = DriverManager.getConnection(ind_server / nome_db,user,password);

Eclipse给我这个错误:

 查询数据包太大(4739923> 1048576)。您可以通过设置max_allowed_pa​​cket变量在服务器上更改此值。 

那么,首先:这个查询真的那么大? -.-
after:哪些命令我必须写在ssh?
这是我第一次到这个东西!
提前感谢!



我在服务器上没有root权限!



尝试使用此:

  mysql> set global max_allowed_pa​​cket = 32 * 1024 * 1024; 

但它给我这个错误:ERROR 1227(42000):Access denied;您需要此操作的SUPER权限



EDIT



max_allowed_pa​​cket变量为32MB。停止并重新启动服务器
但eclipse给了我相同的错误!



我能做什么?

DriverManager.getConnection(URL,用户名,密码)抛出。我甚至得到相同的魔法数字(4739923> 1048576); googling为那些魔术数字将显示结果从人也得到一些DriverManager.getConnection语句抛出的错误。在我的情况下,关于数据包大小的错误消息是完全错误;我只是使用了错误的URL,并且整个事情不得不做数据包大小的任何东西。



也许这将有助于解释我使用的URL是什么 -



我已经成功地连接到远程服务器/数据库与一些数据库管理器,这是一种尴尬(这是一个非常愚蠢的错误。软件叫做SQLYog(类似phpMyAdmin)。为了连接,我不得不给SQLYog 2套东西。首先是URL(或IP地址),用户名,密码和端口,以便我的计算机能够与服务器连接。第二,URL,端口,MySQL用户名,MySQL密码,以便服务器机器可以连接到数据库(位于那台机器上)。因此有2个URL和2个端口(以及2个用户名和2个密码)一个客户端 - >服务器和一个用于服务器 - >数据库。



现在,决定在DriverManager.getConnection中选择JAVA代码的哪个URL,错了一个,蠢id!显然,这必须是第二步(服务器 - >数据库),而不是第一步(客户端 - >服务器);在所有的servlet在服务器上运行之后,所以servlet甚至运行的事实表明步骤1已经被处理,并且步骤2保持完成。由于数据库与servlet正在运行的机器在同一台机器上,所以url只是localhost;或者更确切地说,jdbc:mysql:// localhost:3306 / myDatabaseName。而不是jdbc:mysql://domainNameOfServer.com:somePortNumber / myDatabaseName,它抛出了上述错误。



错误的错误和非常愚蠢的错误信息。我想这是合适的。


I have a big problem! when I do this:

 String query = "SELECT * FROM utente WHERE confermato=1 and Username='" + username
            + "' AND Password='" + password + "'";

        Class.forName("com.mysql.jdbc.Driver").newInstance();
        Connection con = DriverManager.getConnection("ind_server/nome_db","user","password");

Eclipse gives me this error:

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

So, first: this query is really so big? -.- after: which commands do I have to wrtite in the ssh? It' the first time I due with this things! thanks in advance!

I don't have root privileges on the server!

I tried using this:

 mysql>set global max_allowed_packet=32*1024*1024;

but it gives me this error: ERROR 1227 (42000): Access denied; you need the SUPER privilege for this operation

EDIT

Now I have modified the max_allowed_packet variable to 32MB. Stopped and restarted the server But eclipse gives me the same error!

What can I do?

解决方案

I just had to deal with the same error message, thrown by DriverManager.getConnection(URL,username,password). I even got the same "magic numbers" (4739923 > 1048576); googling for those "magic numbers" will show results from people also getting the error thrown by some DriverManager.getConnection statement. In my case, the error message about packet size was COMPLETELY MISLEADING; I simply used a wrong URL, and the whole thing had to do NOTHING with packet size.

Maybe it will help to explain what was wrong with the URL I used - although this is kind of embarrassing (it's kind of a very stupid mistake.) Here it goes.

I had successfully connected to the remote server/database with some "database manager" software called SQLYog (kind of like phpMyAdmin). In order to connect, I had to give SQLYog 2 sets of things. First, URL(or IP adress), username, password, and port, so that my computer can connect with the server. Second, URL, port, MySQL username, MySQL password, so that the server machine can connect to the database (located on that very machine.) So there were 2 URLs and also 2 ports (and also 2 usernames and 2 passwords) one for client -> server and one for server -> database.

Now, deciding on which URL to of those to pick for the JAVA code in DriverManager.getConnection, I picked the wrong one, stupid me! Obviously, that has to be the one for the second step (server -> database), not the first step (client -> server); after all the servlet runs on the server, so the fact that the servlet is even running shows that step 1 is already taken care of, and step 2 remains to be done. Since the database was on the same machine as the machine the servlet was running on, that url was just "localhost"; or, more exactly, "jdbc:mysql://localhost:3306/myDatabaseName". And not "jdbc:mysql://domainNameOfServer.com:somePortNumber/myDatabaseName", which threw above error.

Stupid mistake and very stupid error message. I guess that fits.

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

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