-2

I can't get a solution. my code:

package simple;

import java.sql.*;

public class Dbconnect {

    public static Connection Dbconnector() {

        Connection con=null;
        try {
            con=DriverManager.getConnection("jdbc:mysql://www.merinasoftbd.com:2083/merinaso_inventory management?useSSL=false", "merinaso_inventorymanagement", "inventorymanagement");

            System.out.println("Successfully  connected");

        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return con;
    }
}

the error:

com.mysql.cj.jdbc.exceptions.PacketTooBigException: Packet for query is too large (5,526,600 > 65,535). You can change this value on the server by setting the 'max_allowed_packet' variable. at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:107) at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:862) at com.mysql.cj.jdbc.ConnectionImpl.(ConnectionImpl.java:444) at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:230) at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:226) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at simple.Dbconnect.Dbconnector(Dbconnect.java:18) at simple.mainclass.main(mainclass.java:13)

namokarm
  • 668
  • 1
  • 7
  • 20
md Tusher
  • 1
  • 1

1 Answers1

0

Your error message indicates that your JDBC client sends a packet to the MySQL server that is larger than the server's max packet size. You can increase the max packet size by following the instructions in the answers to this stackoverflow question:

How to change max_allowed_packet size

It seems a bit strange however that the driver needs to send a 5 MB packet just to create a connection. But I normally use much larger MySQL packet sizes, so I wouldn't notice. And please take note that the MySQL packet size has nothing to do with IP packet sizes.

Cuspy Code
  • 184
  • 1
  • 5