从android连接到sql server
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3492417/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
connect to sql server from android
提问by ameni
I'm currently developing a Field-Service application that stores data in the local sqlite database on an android device. At some point, usually after completing the data collection rounds, the local sqlite db is to be synchronized to a remote sql server db on the server, also i need to update some local table from sql server db.
我目前正在开发一个 Field-Service 应用程序,该应用程序将数据存储在 android 设备上的本地 sqlite 数据库中。在某些时候,通常在完成数据收集回合后,本地 sqlite db 将同步到服务器上的远程 sql server db,我还需要从 sql server db 更新一些本地表。
Any suggestions as to how this could be achieved or engineered as a solution? Or even better, are there alternatives to synchronizing data in such an application?
关于如何实现或设计作为解决方案的任何建议?或者更好的是,在这样的应用程序中是否有同步数据的替代方法?
回答by 0xAX
I think that the best is using a intermediary like web services or your own TCP based logic layer for your application which would connect to SQL server and execute requests of your applicatation. Don't try to connect to your SQL server directly from Android. You can write some backend code on your server (or webservice) and then call those code methods from your android device using Http.
我认为最好的方法是为您的应用程序使用像 Web 服务或您自己的基于 TCP 的逻辑层这样的中介,它可以连接到 SQL 服务器并执行您的应用程序的请求。不要尝试直接从 Android 连接到您的 SQL 服务器。您可以在您的服务器(或网络服务)上编写一些后端代码,然后使用 Http 从您的 android 设备调用这些代码方法。
And also there are many themes in stackoverflowlike your:
而且stackoverflow 中有很多主题,比如你的:
About how to write web services. It's a big question, and you must choose technology, there are very many libraries, frameworks and platforms that help you to simply write a web service. You must choose communicating protocol, it may be SOAP, WSDL or maybe remove calling procedure, it may be rest application. If you use java stack, there are some popular frameworks at the moment:
关于如何编写 Web 服务。这是一个大问题,您必须选择技术,有很多库、框架和平台可以帮助您简单地编写 Web 服务。您必须选择通信协议,它可能是 SOAP、WSDL 或删除调用程序,也可能是其他应用程序。如果你使用java stack,目前有一些流行的框架:
You can start from reading what a web service is:
您可以从阅读什么是 Web 服务开始:
Also some links which provide example of accessing web services from android:
还有一些链接提供了从 android 访问网络服务的示例:
回答by kaw
Another and much easier approach is to use a Virtual JDBC Driver that relys on a secured three-tier architecture: your JDBC code is sent through HTTP to a remote Servlet that filters the JDBC code (configuration & security) before passing it to the MySql JDBC Driver. The result is sent you back through HTTP.
另一种更简单的方法是使用依赖于安全三层体系结构的虚拟 JDBC 驱动程序:您的 JDBC 代码通过 HTTP 发送到远程 Servlet,该 Servlet 过滤 JDBC 代码(配置和安全),然后再将其传递给 MySql JDBC司机。结果通过 HTTP 发回给您。
There are some free software that use this technique. Just Google "Android JDBC Driver over HTTP".
有一些免费软件使用了这种技术。只是谷歌“Android JDBC Driver over HTTP”。
回答by Nezam
You would have to keep a middle tier online server.Which may communicate to and fro between your application and MSSQL db.May be servlet or a request handler which synchronises between the SQLite and SQL Server db.
您必须保留一个中间层在线服务器。它可以在您的应用程序和 MSSQL db 之间来回通信。可能是 servlet 或在 SQLite 和 SQL Server db 之间同步的请求处理程序。