简体   繁体   中英

How to connect amazon RDS in iOS

I am making an app in which i was using Amazon Simple db but now i have changed the simple db to amazon rds mysql. Simple db had own api and frame works to access the data base and tables in iOS but how to access amazon rds mysql in iOS any idea how to get this done. They have Amazon have libraries for simple db if there is any other way libaray to use amazon rds in iOS app thanks

Amazon RDS instances are regular MySQL / Oracle / ... databases. You can connect to it from any device or platform, provided you have a driver for it.

There is a C driver for Mysql (see this question How to install MySQL Connector/C on Mac OS X? ) that works on Mac OS X and iOS.

If you want to access RDS MySQL from an iOS application, you must include this driver in your binary distribution and use the functions exposed by the driver from your code.

On an architectural point of view, I however question this approach. There are many benefits to access your database through an API layer (a web application sitting in between your iOS App and the database).

Benefits are : - decoupling : do not expose data structure to client app - scalability : the API can load balance accross DB when using read replica or sharding - security : an API let you enforce authentication and authorisation

I use RDS for my app but I built my own API. It's very fast to do from an EC2 instance (free). All you do is install apache, mysql, and I did php. Then the fastest way is to use one of the PHP frameworks to create routes and use RestKit on your app to decode them.

Your limitations here are that fact that you don't have a jdbc driver to connect your RDS to your iOS app.

So what you need to do is build a rest service(not an easy task), sit it on a Elastic Beanstalk, and connect it to your RDS instance. The apps then hit the rest service through get and post messages. You can use token authentication in your app for security.

You could hack something very easy in PHP(it's what I did my first time), but when I got comfortable launching WAR files into Elastic Beanstalker, I starting looking into Java rest methods. As well as some programs to "map" database tables into Java objects.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM