Why is the paradigm of “direct database connection” not welcomed by the Android platform?

一曲冷凌霜 提交于 2019-11-27 21:44:22
Peter Knego

A few reasons (but not nearly all reasons):

  1. Not existing: there are no (supported) JDBC drivers on Android.

  2. Authentication: you want users on a public network to be authenticated:

    A. Each user must have their own credentials (in some form) when talking to your servers. Having one username/pass baked into your app is asking for trouble.

    B. You don't want your database to provide authentication. For this you need a separate authentication layer.

  3. Standard protocol: if you want to make sure your app runs on all networks (especially on locked-down corporate networks) you need to use HTTP/HTTPS. It's the only protocol that works (almost) everywhere.

  4. Business-logic separation: If you support different device platforms (Android, iPhone, etc..) then it's wise to have all business logic on the server. Instead of calling JDBC and then performing business logic on device, you should do this on the server. That way you will conform to DRY (don't repeat yourself), and also it'll be easier to unit test.

I thought, regardless of the unstable Wi-Fi/3G network bore by most if not all android devices, to connect to a database should be done like so.

You are welcome to your opinion. I vehemently disagree with you. JDBC and similar protocols are designed for reliable, low-latency LANs, not unreliable, high-latency mobile networks. Moreover, you would need your database to be visible on the public Internet, meaning that it will be subject to hackers.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!