Solved [HELP!!] Mysql error with a java application

Discussion in 'Spigot Plugin Development' started by JavaConfig, May 15, 2018.

  1. Sorry if it is not the right forum but I need help!

    I have an error and once a doubt, I want to connect my java application to a mysql, but not to a local mysql. I want it to connect to a mysql of a web hosting. Is this possible to do?

    I tried to do it, but it does not work

    I need help please
  2. ScarabCoder

    Resource Staff

    What's the issue you're having when you say it doesn't work?
    Have you tried using the IP address of your external MySQL server?
  3. How about replacing "localhost" in your connection URL with the host URL?
  4. As @RiotSeb said, you have to replace localhost with the IP of your webhost. I also advise you to make these settings configurable, for example with a config.yml.
  5. It used the ip of my server of mysql but it leaves a message saying that the connection can not be established
  6. Can you post the stacktrace you're getting please? Also keep in mind that you need to define a port after your IP, such as :3306, or what you've configured.

    Edit: please add
    Code (Text):
    after your 'catch' line to receive a stacktrace in your console.
  7. If you are connection to remote database you have to correctly configure MySQL to allow remote connections, this means put in comment the
    Code (Text):
    in your mysql conf. Then you have to open the port if you are using a firewall and add a user to mysql which allows connection on the ip your are connection from. This is of course if you are running your own MySQL server. If you are using a shared hosting it is possible that they do not allow remote connection to their mysql server.
  8. ScarabCoder

    Resource Staff

    Make sure the server can be connected to from outside of it's network. You can test with a MySQL client.
  9. Can you pass the MySQL client to verify?
  10. ScarabCoder

    Resource Staff

  11. Thank you very much for your contribution, I have already solved the error.

Share This Page