I'm tryng to make a connection with an android application to a mysql database, i know a driect connection is not advisable but I can't use a web service. So I've choose jdbc to make this connection but it returns this error:
01-16 11:59:27.681 19064-19064/com.studente.myapplication E/MySQLError:: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
my DB helper class:
private Connection con;
private ResultSet rs;
private static String TAG = "MySQLHandler";
public MySQLHandler(){
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://den1.mysql5.gear.host:3306/pedibustest", "pedibustest", "Aq4T0zWZxf?!");
}catch (Exception ex){
Log.e("MySQLError: ", ex.toString());
}
}
public void testGetData(){
String query = "select * from users";
try{
Statement st = con.createStatement();
rs = st.executeQuery(query);
while (rs.next()){
Log.i(TAG, rs.getString("user_name"));
Log.i(TAG, rs.getString("password"));
Log.i(TAG, rs.getString("indirizzo"));
Log.i(TAG, rs.getString("nome"));
Log.i(TAG, "\n");
}
}catch (Exception ex){
Log.e("MySQLError: ", ex.toString());
}
}
I cant figure out why it's not working, i've added
<uses-permission android:name="android.permission.INTERNET"/>
to the manifest, but it still won't work.