I'm trying to connect my android app with an online database server that uses MySQL
and phpMyAdmin
.
But problem I am having is that I'm unable to access my database (which is online) using Java code for android.
It get the following error:
java.sql.SQLException: No suitable driver at java.sql.DriverManager.getConnection(DriverManager.java:187)
I already loaded the driver and external JAR of MySQL but it is still showing this exception.
The code is :
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection(
"jdbc:mysql:http://www.demo.com:2082/",
"usernme", "password"); //username and password of cpanel access
PreparedStatement statement = con
.prepareStatement("SELECT * FROM users WHERE userName = '"
+ userName + "'");
ResultSet result = statement.executeQuery();
while (result.next()) {
retrievedUserName = result.getString("username");
Log.e("data username:", retrievedUserName);
retrievedPassword = result.getString("password");
}