Issue connecting my APP into the Database

Website URL

Its an app in development

Error Message

Caused by: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

Caused by: java.net.UnknownHostException: No such host is known (sql301.infinityfree.com)

Other Information

I made an app that works locally and wanted to expand it in order to use a hosting service for its Database. I have created an InfinityFree account with the free plan and created a new database. Using phpadmin I created the tables like the ones I had in my local workbench database.
Now the issue is that when I try to connect it gives me multiple errors of access and I dont know if its because I’m in a free plan or something else

JAVA
Connection code:

Connection connection = DriverManager.getConnection(“jdbc:mysql://sql301.infinityfree.com:3306/if0_38580586_cacatrackerinfinityfree”, “if0_38580586”, “password”);

Hi and welcome to the forum! MySQL remote access is not available on free hosting.

8 Likes

So can you confirm that if I pay premium I can access it? Because when I click premium it takes me to iFastNet and I dont know if its the same

iFastNet provide the premium plans. I’m not sure if they let external apps access the sql database though

4 Likes

InfinityFree does not provide premium hosting, iFN is the partner that does.

As far as I am aware, remote SQL is supported, but ask at support.iFastNet.com to be 100% sure.

8 Likes

iFastNet does support remote MySQL on all their plans.

However, I would like to clearly state that connecting a mobile app to a database is a very bad idea. Anyone who has access to the mobile app can extract your database credentials, and use that to read and write any data they want. Premium hosting has the option to create database users with limited permissions, but those are not so fine grained that you can limit access to specific data.

That’s why it’s more common to have a server side application in between. The server side application can expose a HTTP API that your app can talk to, and that server application stores the data in the database. And in that server application, you can implement whatever authentication or access controls are needed for your app.

7 Likes