oracle iPhone:通过 Internet 连接到数据库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/947835/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 18:19:52  来源:igfitidea点击:

iPhone: Connecting to database over Internet?

iphonemysqldatabaseoracle

提问by TheGambler

I've been talking with someone about the possibility of a iPhone development contract gig. All I really know at this point is that there is a company that wants to make an iPhone app that will hit their internal database. I'm not sure what the database type is( Oracle, MySQL, etc...).

我一直在与某人谈论 iPhone 开发合同演出的可能性。在这一点上,我真正知道的是,有一家公司想要制作一款能够访问其内部数据库的 iPhone 应用程序。我不确定数据库类型是什么(Oracle、MySQL 等...)。

I've wanted to know if the database type was Oracle or MySQL if there is a big learning curve for connecting to one of these across the internet?

我想知道数据库类型是 Oracle 还是 MySQL,如果通过 Internet 连接到其中之一的学习曲线很大?

If it's a real pain I may do more research before accepting the conract.

如果这是一个真正的痛苦,我可能会在接受合同之前做更多的研究。

回答by fretje

I would advise against directly accessing the database from the iPhone application.

我建议不要直接从 iPhone 应用程序访问数据库。

Usually, you would create a web service which accesses the database, and then you consume that web service from the iPhone application.

通常,您会创建一个访问数据库的 Web 服务,然后从 iPhone 应用程序使用该 Web 服务。

回答by AFHood

Create a web service. This allows you to make the iphone app more of a thin client. Let the application push commands to the web service for processing and interaction with the database returning only the data needed by the app.

创建一个网络服务。这使您可以使 iphone 应用程序更像一个瘦客户端。让应用程序将命令推送到 Web 服务以进行处理并与数据库交互,仅返回应用程序所需的数据。

This option is better for the app, the database, and the customer's security.

此选项对应用程序、数据库和客户的安全性更好。

回答by user861361

Those answers from 2009 are mostly obsolete now.

2009 年的那些答案现在大多已经过时了。

http://ODBCrouter.com/ipad(new) has XCode client-side ODBC libraries, header files and multi-threaded Objective C objects that let your apps send SQL to server-side ODBC drivers and get back binary results! This reduces the need to stop and separately maintain SOAP/REST servers that can get pretty frightening anyway after a while maintaining it.

http://ODBCrouter.com/ipad(新)具有 XCode 客户端 ODBC 库、头文件和多线程 Objective C 对象,让您的应用程序将 SQL 发送到服务器端 ODBC 驱动程序并返回二进制结果!这减少了停止和单独维护 SOAP/REST 服务器的需要,这些服务器在维护一段时间后无论如何都会变得非常可怕。

The XML schemes were okay for transferring static configurations to mobile devices "every once in a while", but XML was meant for infrequent inter-company type transfers in a "server environment" (with power cords, wired networks and air conditioning) and is definitely not efficient for frequent database queries coming in from n-copies of a mobile app. There are third-party JSON libraries that help things, but even with JSON, everything has to be encoded (and decoded) from the binary representation in the database to text representation on the server (only fine if it's going to be shown to the user in a web browser anyway, but not fine if the mobile app is going to translate it right back into binary so that it can perform calculations "behind the scenes" to what is going on with the user). Aside from the higher network overhead and battery power the mobile CPU will draw with XML and JSON, it will also make you buy more RAM and CPU power on the back-end server faster than just using an ODBC connection to the database.

XML 方案适用于“每隔一段时间”将静态配置传输到移动设备,但 XML 用于“服务器环境”(带有电源线、有线网络和空调)中不频繁的公司间类型传输,并且是对于来自移动应用程序的 n 个副本的频繁数据库查询,绝对效率不高。有第三方 JSON 库可以提供帮助,但即使使用 JSON,也必须对所有内容进行编码(和解码),从数据库中的二进制表示到服务器上的文本表示(只有在将其显示给用户时才可以)无论如何,在网络浏览器中,但如果移动应用程序将其直接转换回二进制,以便它可以“在幕后”执行用户正在发生的事情的计算,那就不好了)。

回答by Heat Miser

You can easily perform the connection over the internet, the same way you would locally, but you are opening the database up to attacks if it will accept communication from any remote IP address. Typically you will just connect via a socket open to the server's remote IP address over the open port, MySQL's default port is 3306.

您可以轻松地通过 Internet 执行连接,与本地连接的方式相同,但如果数据库接受来自任何远程 IP 地址的通信,则您将打开数据库以应对攻击。通常,您只需通过开放端口打开一个套接字连接到服务器的远程 IP 地址,MySQL 的默认端口是 3306。

I would recommend against this sort of system in general unless there is some critical reason they want their internal database exposed to the world's hacker community.

我一般会建议不要使用这种系统,除非有一些关键的原因他们希望他们的内部数据库暴露给世界黑客社区。

回答by Anh Do

What I am doing is creating a web service using Sinatrato access the online database.

我正在做的是使用Sinatra创建一个 Web 服务来访问在线数据库。