title: Error 'Packet for query is too large' when I tried to make a query on my website
body: <p>Again I need your help. 
  I'm trying to put my java web site online. </p>
  
  <p><strong>What I use :</strong> </p>
  
  <ul>
  <li>MySQL server : command line mysql -V, <strong>result</strong> : mysql  Ver 15.1 Distrib 10.1.23-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2</li>
  <li>Cayenne</li>
  <li>Debian server</li>
  <li>Java (Vaadin)</li>
  </ul>
  
  <blockquote>
    <p>Packet for query is too large (4739923 > 1048576). You can change this
    value on the server by setting the max_allowed_packet' variable.</p>
  </blockquote>
  
  <p><strong>What I tried :</strong> </p>
  
  <p><strong>1.</strong> Like the error said, I tried to change the value on the server by doing : </p>
  
  <ul>
  <li>Log on my server </li>
  <li>Connect to MySQL with : <code>mysql -u root</code></li>
  <li>Enter : <code>SET GLOBAL max_allowed_packet=1073741824;</code></li>
  <li>then, restart the server with : <code>/etc/init.d/mysql restart</code></li>
  </ul>
  
  <p>But I still have the error. </p>
  
  <p><strong>2.</strong> I took a look to : <a href="https://stackoverflow.com/questions/8062496/how-to-change-max-allowed-packet-size">How to change max_allowed_packet size</a></p>
  
  <p>But, When I did the <code>nano /etc/mysql/my.cnf</code>, the file looks like (I don't have any [mysql]) :</p>
  
  <pre><code>Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
  permitted by applicable law.
  Last login: Fri Nov 10 23:57:02 2017 from 82.236.220.195
  root@XXXX:~# nano /etc/mysql/my.cnf
    GNU nano 2.7.4               File: /etc/mysql/my.cnf                Modified
  
  # One can use all long options that the program supports.
  # Run program with --help to get a list of available options and with
  # --print-defaults to see which it would actually understand and use.
  
  #
  # This group is read both both by the client and the server
  # use it for options that affect everything
  #
  [client-server]
  # The MariaDB configuration file
  #
  # The MariaDB/MySQL tools read configuration files in the following order:
  # 1. "/etc/mysql/mariadb.cnf" (this file) to set global defaults,
  # 2. "/etc/mysql/conf.d/*.cnf" to set global options.
  # 3. "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options.
  # 4. "~/.my.cnf" to set user-specific options.
  #
  # If the same option is defined multiple times, the last one will apply.
  #
  # One can use all long options that the program supports.
  # Run program with --help to get a list of available options and with
  # --print-defaults to see which it would actually understand and use.
  
  #
  # This group is read both both by the client and the server
  # use it for options that affect everything
  #
  [client-server]
  
  # Import all .cnf files from configuration directory
  !includedir /etc/mysql/conf.d/
  !includedir /etc/mysql/mariadb.conf.d/
  </code></pre>
  
  <p>In mysql, the folders/files in the 'mysql' folder is : </p>
  
  <p><a href="https://i.stack.imgur.com/snpV4.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/snpV4.jpg" alt="enter image description here"></a></p>
  
  <p>Any hint will be very appreciate! 
  Thanks</p>
  
  <p><strong>EDIT:</strong> In <code>/etc/mysql/mariadb.conf.d/50-server.cnf</code>, I changed :</p>
  
  <ol>
  <li><code>max_allowed_packet = 1073741824</code></li>
  <li><code>max_connections = 100000</code></li>
  </ol>
  
  <p>and I added : <code>net_buffer_length   = 1048576</code></p>
  
  <p>For info : 
  In my workbench, I can see the server variables : 
  <a href="https://i.stack.imgur.com/WuWzM.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WuWzM.jpg" alt="enter image description here"></a></p>
  
  <p>EDIT2 : Now, when I select the variable in command line on the server, I have : </p>
  
  <pre><code>MariaDB [(none)]&gt; SELECT @@global.max_allowed_packet;
  +-----------------------------+
  | @@global.max_allowed_packet |
  +-----------------------------+
  |                  1073741824 |
  +-----------------------------+
  1 row in set (0.00 sec)
  </code></pre>
  
  <hr>
  
  <p><strong>SOLUTION Because the error was not explicit.</strong></p>
  
  <p>Thanks to <a href="https://stackoverflow.com/questions/13759418/com-mysql-jdbc-packettoobigexception">com.mysql.jdbc.PacketTooBigException</a></p>
  
  <p>My cayenne configuration was : </p>
  
  <pre><code>&lt;url value="jdbc:mysql://IPADDRESS:22/DBBASENAME" /&gt;
  &lt;login userName="ServerUserName" password="ServerPassword" /&gt;
  </code></pre>
  
  <p>But it should be : </p>
  
  <pre><code>&lt;url value="jdbc:mysql://IPADDRESS/DBBASENAME" /&gt;
  &lt;login userName="MYSQLUserName" password="MYSQLPassword" /&gt;
  </code></pre>