I am facing this problem of communications link failure while connecting my android app to remote mysql database.
JAR File Used: mysql-connector-java-5.1.31-bin
Remote sql information: innodb_version: 1.0.17-13.3
protocol_version: 10 version: 5.1.62-rel13.3-log
version_comment: Percona Server (GPL), 13.3, Revision 435
version_compile_machine: x86_64
version_compile_os: unknown-linux-gnu
I tried using mysql workbench to connect to remote database and it works perfectly. But with my android app, I get a communications link failure. I don't think there is anything wrong with my connection preferences as those are the same that I am using in workbench or to connect via terminal (on mac & it works).
Also, I think the jdbc driver I am using is also fine. Can anyone make any other suggestions as to what the problem could be?
Here is the complete exception:
07-07 02:59:10.568: D/QueryException(1745): Exception in connection Communications link failure
07-07 02:59:10.568: D/QueryException(1745): The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Here is the part of code causing exception in Logcat:
connection = DriverManager.getConnection("jdbc:mysql://<hostname_goes_here>/<database_name>","<username>","<password>");
if(connection!=null){
Log.d("Connecting to remote server", "Remote sql server connection successful");
}
else{
Log.d("Connection failure", "Could not connect to remote sql server with host "+hostName);
}
} catch(Exception e){
Log.d("QueryException","Exception in connection "+e.getMessage());
System.out.println("Caught exception while connecting to database "+e);
e.printStackTrace();
}
0 comments:
Post a Comment