I am trying to connect to my database which is hosted on 000webhost. I am connecting from SmartFoxServer, and they allow database connections. All you have to do is change some of the settings in the smartfoxserver xml file.
I have successfully managed to connect to my localhost mysql database using these settings.
 <databaseManager active="true"> <connectionString>jdbc:mysql://localhost:3306/db_name</connectionString> <userName>root</userName> <password></password> <testSql>SELECT id FROM users LIMIT 1</testSql> </databaseManager> But when I tried to connect to my external database which is hosted on 000webhost and looks like this:
Using these settings
<connectionString>jdbc:mysql://mysql2.000webhost.com/a5939459_data</connectionString> <userName>a5939459_user</userName> <password>censored</password> <testSql>SELECT id FROM users LIMIT 1</testSql> I get the following error...
Exception: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException Message: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driv er has not received any packets from the server. Description: The DBManager Test SQL failed Please double check your SQL code and make sure that Database server is running. EDIT:
But when I run php files on my localhost and ask for database connection like this, it works
<?php $db_username = "a5939459_user"; $db_name = "a5939459_data"; $db_password = "censored"; $db_host = "mysql2.000webhost.com"; mysql_connect($db_host,$db_username, $db_password, $db_name); mysql_select_db($db_name) or die (mysql_error()); ?> 
