0

I normally use WebServices to retrieve Data from DB in form of JSON , as i believe all mobile apps should follow the async and services architecture.

However , i across this post which says we can directly access DBs like MySQL using an JDBC Driver-How to connect Android with MySQL using Mysql JDBC driver.

I understand method 1 requires less plumbing on mobile app as we just have to parse JSON in that case ,but is there any difference in perfomance between two methods? Which one is more preferred?

Community
  • 1
  • 1
raghu_3
  • 1,849
  • 3
  • 18
  • 29
  • 1
    "Which one is more preferred?" -- use a Web service, for much the same reason why you don't access a MySQL database directly from a Web browser. Opening your database to the world and giving ~8 billion people your database account credentials is not an especially wise move, even if it is technically possible. – CommonsWare Feb 04 '14 at 00:05

2 Answers2

2

In rare circumstances A MySQL direct connection makes sense. Very rare.

The security risks are real. Data is not securely transmitted without other measures being taken and your database is exposed on the server where it is hosted.

In a closed network environment where you have specific build requirements due to your employer or client or other specific resource constraints where you are required to do so, then maybe...

Although the direct connection might be faster for small numbers of clients and even require less of a learning curve for others besides yourself with your experience, it is not worth the risk. For large numbers of clients, the cost of not using middleware optimization tools becomes a hinderance to performance. With middleware you are able to pool connections, use query caching, use pre-compiled queries, etc.

Jim
  • 10,172
  • 1
  • 27
  • 36
0

Connecting to Database directly from mobile phones is beyond insane. I am surprised someone here suggested that. He should get fired. It has both security and scaling issues. So, stay away from that suggestion.

Arya
  • 2,135
  • 15
  • 13