Yonah Karp
Yonah Karp

Reputation: 671

Trouble connecting to remote mysql (phpmyadmin) server from java (intellij)

I'm working on a project and I have a java program that parses a bunch of files and breaks them into records which are to be stored within a database. I've tested the program on my own server using the following (intellij generated) string:

enter image description here

And the above string works fine in the code and all the data is stored

But when I try to connect to the (external) project database located at 104.131.96.199 using the following

enter image description here

(There are two open ports: 22 and 80)

On port 80 it hangs on "connecting to database" forever (over 10 mins),

and on port 22 I get the packet size error above.

I've gone into phpmyadmin and changed the max_allowed_packet variable to 4739923, but still get the same issue (the change still isn't reflected in the error).

I'm not in charge of this db, although I have the admin user and pass. Any help in the matter would be greatly appreciated

I guess I have 2 questions:

  1. Is my connection string syntactically correct (and if not what should it be)
  2. If the string is correct, what to do about the packet size issue / hanging forever

Upvotes: 0

Views: 856

Answers (2)

rocket_doge_
rocket_doge_

Reputation: 185

1.) Yes, the URL is syntactically correct. If you want to specify a user and password, you can add ?user=<username>&password=<password> to the end of the String.

2.) It most likely doesnt work because you are apparently using the SSH port (22) and the HTTP port (80) instead of the MySQL port (3306). If these are the only two open ports you will have to ask the server admin to manually allow remote connections to his MySQL server

Upvotes: 1

J_D
J_D

Reputation: 736

  1. Syntax is correct.

  2. packet size issue - The changes to max_allowed_packet have possibly not taken effect. Run the below to check the value:

    SHOW VARIABLES LIKE 'max_allowed_packet';

    hanging forever - Check that the port used is correct.

Upvotes: 0

Related Questions