i have been trying to connect to my mysql server using java and Android studio but no luck, i looked up all over the internet but still no success.. my code:
CharSequence text = "Trying...";
int duration = Toast.LENGTH_SHORT;
Context context = getApplicationContext();
Toast wel = Toast.makeText(context, text, duration);
Toast err = Toast.makeText(context, "Conntection Failed", duration);
Toast suc = Toast.makeText(context, "Conntection Success", duration);
Connection con = null;
String url = "jdbc:mysql://...../?user=....";
if(con == null) {
try {
DriverManager.getConnection(url, "username", "pass");
suc.show();
}catch (SQLException ex){
// handle any errors
err = Toast.makeText(context, ex.getMessage(), duration);
err.show();
}
}
I already used this command:
<uses-permission android:name="android.permission.INTERNET"/>
and I downloaded the jdbc connector.. my error is: "could not create connection to database server" any idea?