0

anybody knows how to connect MYSQL to android studio using MYSQL workbench. I have tried all methods, it shows following error.

com.mysql.jdbc.CommunicationsException: Communications link failure due to 
underlying exception: 
01-17 16:21:56.845 30367-30442/animaltracking.kevell.com.myapplication 
W/System.err: ** BEGIN NESTED EXCEPTION ** 
01-17 16:21:56.845 30367-30442/animaltracking.kevell.com.myapplication 
W/System.err: java.net.SocketException
01-17 16:21:56.845 30367-30442/animaltracking.kevell.com.myapplication 
W/System.err: MESSAGE: java.net.ConnectException: Connection refused
  • 1
    [Don't do this please](https://stackoverflow.com/questions/29046305/can-android-connect-directly-to-mysql-without-php). Exposing your MySQL instance to the outside opens up a big potential security hole. Rather, maintain a web server which in turn talks to MySQL, and then open up your web server to the outside. – Tim Biegeleisen Jan 17 '19 at 10:56
  • Hi, could you please tell how to do this, i am not much known about this – Noorul Haarisha Jan 17 '19 at 11:09
  • use volley dependencies – Alpesh Savaliya Jan 17 '19 at 11:14
  • Just expose your data building a REST API layer. Exposing data by directly connecting to the database is a very bad practice – Gregorio Palamà Jan 17 '19 at 11:17

2 Answers2

1

You can use the following link to connect third-party database By using rest web services or web services:-

Link:-https://www.youtube.com/watch?v=Ucs-blvF3d8&t=1096s

NOTE:- Use Volley or Volley plus, Retrofit, HttpOk

Rahul Patel
  • 326
  • 2
  • 10
0

You should not do this. Instead you should use REST APIs to communicate with database.

https://android.jlelse.eu/consuming-rest-api-using-retrofit-library-in-android-ed47aef01ecb

Mohit
  • 505
  • 8
  • 31