dongli564510 2015-01-18 23:17
浏览 55

MySQL数据库没有连接到Android应用程序

My database is running fine because I tested it using Eclipse with simple Java code that just connects and reports back success or fail. I connect fine....I can even read and write to it there.

Now, when I try to do the same thing in Android Studio,the connection fails. I am on the same WiFi network.

I created a lib folder for the app and put all the extra .jar files there including the JDBC connector for MySQL that I used in Eclipse. I also went to the build.gradel file and added the line:

compile files('libs/mysql-connector-java-5.1.34-bin.jar')

Do I need to make a PHP API for it to connect since right now I am trying to connect to it using this line:

 connection = DriverManager.getConnection("jdbc:mysql://localhost:port/testdb", "user", "password");  

Any suggestions?

  • 写回答

1条回答

  • douzhang8840 2015-01-18 23:52
    关注

    If you haven't you should declare your permission <uses-permission android:name="android.permission.INTERNET" />.

    Then you may want to use something like JSON to make database requests from PHP.

    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题