Reputation: 135
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?
Upvotes: 0
Views: 1195
Reputation: 43
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.
Upvotes: 2