connecting java application with online hosted mysql database

人走茶凉 提交于 2019-12-03 17:22:01

I faced the same issue and the following helped me to solve.

http://support.hostgator.com/articles/cpanel/how-to-connect-to-the-mysql-database-remotely

Hopefully, your hosting provider should have same type of cpanel to configure MySQL database for remote connections.

sumanta
  1. Check for firewall.
  2. Check if mysql is running.

2 things you can try:

  1. Install MySql client locally on your machine and connect like: mysql -h fdb12.biz.nf -u 1738412_wstore -P<password>

This should work before you try anything else.

  1. Make sure you're using the right imports in your code. See [here][1].

    import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException;

I think your DB server doesn't allow remote connections.

Try hosting in:

http://www.freesqldatabase.com/freemysqldatabase/

It's free and allow remote DB connections.

Good Luck!!!

Considering the Biz.nf FAQ:

How can I connect to my MySQL/PostgreSQL database? What settings should I use for my script/software?

MySQL/PosgreSQL database connection can be established with script/software hosted only on your web hosting account (meaning no remote access is allowed due to security reasons). The following settings are needed:

So, since biz.nf does not allow remote access, it will be difficult for you to interact with their MYSQL server for your application.

The best solution and the most simple is probably to find a new provider which will allow the remote access. Heroku.com works very well.

If you really want to use the biz.nf services, it will be more difficult.

It's not a script or credential problem.

Maybe you can (probably not), try to login by SSH to configure your server to enable remote access to your MYSQL database server.

From the free plan, you will not have any access to the online SSH tool and you will need to configure your domain for a SSH connection.

In SSH, and it probably will not work considering the FAQ, you could try to simply modify your /etc/mysql/my.cnf file by commenting the bind-address line wich by default only allows local access (127.0.0.1). Then, try to restart your MYSQL service with: a simple service mysql restart to verify if the remote connection works.

If the remote connection still doesn't work after this, the only way I can find for the moment (unless you completely change your hosting provider) would be to create a kind of API hosted directly on the server and your Java program could interacts with your services (In JSON, by example).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!