I created a mySQL database on 000webhost and I wanted to connect it into my Java program but somehow driver aren\'t receiving sockets. Here is my code:
Class.for
Please remove the table name from the connection string.
just write
Connection conn = DriverManager.getConnection("jdbc:mysql://mysql2.000webhost.com/a4931569_users", username, pass);
JDBC URL Format
The JDBC URL format for MySQL Connector/J is as follows, with items in square brackets ([, ]) being optional:
jdbc:mysql://[host][,failoverhost...][:port]/[database] »
[?propertyName1][=propertyValue1][&propertyName2][=propertyValue2]...
If the host name is not specified, it defaults to 127.0.0.1. If the port is not specified, it defaults to 3306, the default port number for MySQL servers.
jdbc:mysql://[host:port],[host:port].../[database] »
[?propertyName1][=propertyValue1][&propertyName2][=propertyValue2]...
Here is a sample connection URL:
jdbc:mysql://localhost:3306/sakila?profileSQL=true
Please refer http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-configuration-properties.html
Edit
In case of
It says: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
you need to go with answer of Math.
MySQL from 000webhost doesn't allow you to connect from external applications, just from within pages hosted in their domain.
Please check: How can I connect to MySQL from my computer?