qq_37761523
2017-05-30 13:59android利用JDBC连接服务器mysql失败
加载的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或者断网出现的都是同样的信息,求帮助
- 点赞
- 回答
- 收藏
- 复制链接分享
2条回答
为你推荐
- Android直连MySQL ,无法建立连接
- android-studio
- connection异常
- mysql
- 3个回答
- android直接连接mysql时,从返回的resultset取数据时出错
- android
- mysql
- 7个回答
- 服务器端可不可以只是跑个MYSQL数据库?还有android APP开发属于什么开发架构?
- 数据库
- android
- 架构
- 服务器
- 1个回答
- 有木有哪位前辈用mysql直接连接android的
- android
- mysql
- 5个回答
- 安卓开发报错Illegal operation on empty result set.
- android
- 1个回答
换一换