为什么是&QUOT范式;直接数据库连接"不是由Android平台的欢迎?是由、范式、数据库连接、直接

由网友(指尖的流沙﹌)分享简介:当我说直接数据库连接,我的意思是使用JDBC驱动程序一样打电话和运行活动的范围内的远程数据库查询,就像使用SQLite数据库来存储本地参数。When I say "Direct Database Connection", I meant to use JDBC alike driver to call and run...

当我说直接数据库连接,我的意思是使用JDBC驱动程序一样打电话和运行活动的范围内的远程数据库查询,就像使用SQLite数据库来存储本地参数。

When I say "Direct Database Connection", I meant to use JDBC alike driver to call and run a remote database query within the context of an activity just like using SQLite database to store the local parameters.

直到我意识到,我几乎找不到了关于这种方法的数据库连接的网络的任何教程或文件,我想,不管是不稳定的Wi-Fi无线/ 3G网络孔的大多数,如果不是所有的Andr​​oid设备,连接到数据库应该做像这样。

Until I realized that I could barely find any tutorials or documents over the internet regarding this way of database connection, 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.

即使在Android SDK中,只有本地数据库访问(又名android.database.sqlite)在本质上是支持的。而且它在的java.sql 的API,您必须提供才能使用这个API自己的JDBC驱动程序

Even in android sdk, only local database access (a.k.a android.database.sqlite) is supported intrinsically. And it's stated in the description of java.sql API that you must provide your own JDBC driver in order to use this API.

然后,我开始意识到,如果我直接连接数据库的意图是不正确的在机器人领域中的第一名。

Then I started to realize if my intention of directly connecting a database is incorrectly in the first place in the realm of android.

我看了很多书,维基和论坛包括Stackflow提供了很多答案,在我看来,很多人都专注于得到的东西做的,用于启动与讨论,我怎样才能设计出一个RESTful Web服务我的Andr​​oid设备,但是我需要的是深入的了解!而且我也需要从原生Android开发权威的引文。

I have read many books and wikis and forums including numerous answers provided in "Stackflow", it appears to me that many people are concentrating on getting something done, discussions used to start with "How can I design a Restful web service for my android device", however what I need is thorough understanding! And I also need authoritative citations from original android developers.

可能有人向我提供了相当数量对此事的见解?很多预先感谢您!!

Could somebody provide me a fairly amount of insights on this matter?! Lots of thank you in advance!!

推荐答案

几个原因(但不是几乎所有的原因):

A few reasons (but not nearly all reasons):

不存在:有在Android上没有(支持)的JDBC驱动程序

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

认证:你想要一个公共网络上的用户进行身份验证:

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

一个。交谈时,您的服务器每个用户都必须有它自己的凭证(以某种形式)。有一个用户名/密码烤到您的应用程序是自找麻烦。

A. Each user must have it's 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.

标准协议:如果你要确保你的应用程序在所有网络上运行(尤其是锁定的企业网络),你需要使用HTTP / HTTPS。这是该作品(几乎)无处不在的唯一协议。

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.

业务逻辑分离:如果您支持不同设备平台(安卓/ iPhone /等)比其明智的,有在服务器上所有的业务逻辑。而不是调用JDBC,然后在设备中执行业务逻辑,你应该在服务器上执行此操作。这样,你会遵循DRY(不要重复自己),也它会更容易进行单元测试。

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

阅读全文

相关推荐

最新文章