Question
can't connect to MySql from Java remotely
I tried connecting to MySQL from Java,
Class.forName(“com.mysql.jdbc.Driver”).newInstance();
java.sql.Connection conn1 = null;
conn1 = DriverManager.getConnection(“jdbc:mysql://mydomain.com/databaseName”,“mySQLusername”,“mySQLPassword”);
conn1.close();
com.mysql.jdbc.PacketTooBigException: Packet for query is too large (4739923 > 1048576). You can change this value on the server by setting the maxallowedpacket’ variable.
at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:569)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1013)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2234)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2265)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2064)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:790)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:44)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:377)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:395)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:325)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:207)
at org.com.setuserv.TwitterSearchAPITweak.twitterDataToDB(TwitterSearchAPITweak.java:237)
at org.com.setuserv.TwitterSearchAPITweak.main(TwitterSearchAPITweak.java:32)
I changed the maxallowedpacket = 16M, but it’s still showing the same error. I tried to connect to local mysql database and a friend’s machine on the intranet, it worked. Could that be a digitalOcean problem
Thanks in advance.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×
You confirmed that the option is being read correctly before restarting mysql:
it shows
@rahulreddy - you can eliminate the double-dash in front of the group name mysqld. My version allows the double-dash as well as just the mysqld options group.