加载的mysql驱动是mysql-connector-java-5.1.30-bin.jar
服务器是腾讯云服务器
代码:
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = (Connection) DriverManager.getConnection(
"jdbc:mysql://118.89.232.64:3306/info_file","name","password");
Log.i("mysqltest","Success connect Mysql server!");
}catch( SQLException ee)
{
Log.i("mysqltest","Error loading Mysql Driver!ee");
ee.printStackTrace();
}
catch (Exception e)
{
Log.i("mysqltest","Error loading Mysql Driver!e");
e.printStackTrace();
}
程序能打开,但是不能与数据库建立连接,log信息:
05-30 20:04:35.614 8362-8362/? W/System.err: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
05-30 20:04:35.614 8362-8362/? W/System.err: The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
而且就算乱改url或者断网出现的都是同样的信息,求帮助