到了每学期的课程设计,这次是关于数据库的课设。在自己的课设项目中,采用android直连mysql数据库实现数据的增删改查功能。
但光一个连接MySql就花费了我一天时间。目前遇到的主要问题是:
1.出现:Could not create connection to database server. Attempted reconnect 3 times. Giving up
网上查阅资料,是说将连接的URL改为:
url=jdbc:mysql://localhost:3301/dream?useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&failOverReadOnly=false
但仍然没有什么用
2.出现The last packet sent successfully to the server was 0 milliseconds ago.
3.出现The last packet successfully received from the server was *** millisecond ago问题
网上查阅资料各种答案,很复杂,试了很多都没用
最后发现,android虚拟机访问电脑服务,不能用localhost或127.0.0.1,而是得用10.0.2.2(当再改回localhost或127.0.0.1时,会发现还是会出错)
最后改回10.0.2.2时成功连接数据库。。。。。
原因还在查询中。。。。