1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

iPhone connect to Oracle DB

Discussion in 'iPhone/iPad Programming' started by dezigny, Jul 26, 2010.

  1. macrumors newbie


    First let me be clear that I'm a NEW iPhone developer, so be easy :)

    I'd like to know the best way to design an iPhone application that will connect remotely to an Oracle DB and fetch data to display it on the screen.

    Thanks in advance
  2. macrumors 603


    You are probably best off accessing the database through a web service. The alternative is trying to compile the Oracle C / C++ or Objective-C database driver for ARM so you can statically link it with your iPhone app and access the database directly.

    Assuming of course Oracle release the source code of their database drivers.
  3. macrumors newbie

    Appreciate your reply Cromulent ;)

    OK, lets go one by one, Let me first understand a WebService :)

    Is it like a stored procedure that accept inputs and send outputs back?

    And what is the best tool that to create a WebService than iPhone can interact with?

    And what is the method in Xcode to communicate with a WebService?

    Last for now :) Do I need to configure SSL certificate to tighten the security between the app and the WebService and the database?

    Thanks in advance guys ;)
  4. macrumors 603


    No it has nothing to do with stored procedures.

    A web service is basically just a website that emits raw XML or JSON rather than HTML. You just consume that XML or JSON with your iPhone app, the website deals with accessing the database and you can use any language you want for it (Python, Ruby and *puke* PHP are all popular as are Java and C#).

    SSL is always a good idea especially if you want the data available only to authorised clients.

    You'll need to write the communication stuff yourself. Just use the appropriate NSHTTP classes.

    Best tool for creating a web service? Text editor + Python + Django is my favourite but I'd be loathed to say it is the best. It is extremely good though.
  5. macrumors 68000

    Have you searched Oracle to see what they have. Such as: Oracle Business Indicators. They also mention creating an iPhone Web app here.

    Oracle DBAs usually don't like people accessing 'their' databases without permission or via non-authorized methods. You should be talking to your DBA about what possibilities exist.

    ODBC may be an option if there is a compatible driver for iPhone developers.
  6. macrumors newbie

    Thanks again Cromulent for your reply, although still I didn't get a clear picture regarding the web service that Xcode can interact with and retrieve desired data from Oracle DB :)

    I need a short/clear example/tutorial on how can I create a Web Service that reads lets say [Employee_Name] from [Employees] Table based on [Employee_ID]. Then how Xcode can send the [Employee_ID] and display the [Employee_Name]

    Sorry if I'm asking too much, but really I was googling for couple of days without reaching any where!

    xStep, many thanks for the 2 links :cool: but the first link was only for Oracle Business Indicators which only enables you to access Oracle Reports, while I'm looking to access Oracle Tables, please correct me if I'm wrong.

    The second link was on how to create a Web app which is not my target, I'm planning to create a Windows based application that interact with Oracle DB wither via Web Service or any other middle-were :)

    Thanks again guys for your replies, I highly appreciate it :cool:
  7. macrumors newbie


    The trick to solving these kinds of problems is to break it into smaller parts.

    In simpler terms, a web service is a website that fetches the data you request. You can use your web language of choice (ASP.NET, PHP, Python, Java, whatever) to build it.

    I'm sure you've seen addresses like "http://www.server.com/user.php?id=10" This might display a profile for user with ID=10 in the database. What does this do under the hood? It runs a MySQL/Postgres/Oracle/etc. query that might say SELECT * FROM user WHERE id=10.

    While iOS SDK may not have Oracle libraries as other people wrote, you can load webpages without much effort. So your first step would be to add simple code that loads data from a webpage, any webpage. Can you load the text for http://www.google.com/ into an NSString?

    Your second step would be to make a webpage that accepts some parameters (like the 'id' you saw my above example) and reads something from the database based on that.

    Hope this helps!
  8. Moderator


    Staff Member

    Just so you know, dezigny , most of what you will be doing to set up the web service will have nothing to do with iPhone Programming and everything to do with whatever capabilities your database / application server / etc. have on the backend. Good luck, though!
  9. macrumors 68000

    Windows as in Microsoft Windows, or as in a GUI window system?

    The iPhone web app link might be something to look at to understand what it is you'll do with a web service. Specifically a web service that may already exist and be useful to you.

    If your company (I assuming you work at a company) is in good standing with Oracle, you or the designated contact person should be able to open a ticket with Oracle asking what your options are.
  10. macrumors newbie

    Cromulent is saying you need to expose your database to your iPhone app through a web page that takes parameters (of stored procedure) and returns the data as xml:

    NSURL *URL=[[NSURL alloc] initWithString:mad:""];
    NSString *results = [[NSString alloc] initWithContentsOfURL :URL];

    But you don't need to setup your own web server. Oracle has webservices built in. Read more here:

  11. macrumors 68030



    This thread is two years old. The guy you're responding to hasn't logged on in about 18 months.
  12. macrumors newbie

    The message wasn't for him obviously.... This thread is the top result when you google "iOS oracle client library". The web service is still the only solution. Why don't YOU quit wasting everyone's time and try posting something helpful for people that might be researching the topic ;)
  13. macrumors 68030


    OK. I'll post something useful.

    Don't ever use this code:

    NSString *results = [[NSString alloc] initWithContentsOfURL :URL];
    Synchronous networking is harmful to your health.
  14. macrumors newbie

    1. Allowing direct access to your DB from the outside is a security risk unless you really know what you are doing. I don't recommend it.

    2. Writing a web service in a language such as PHP or Ruby on Rails that accesses the DB for you is usually considered the best idea. But there are security concerns here as well.

    Since you are using Oracle, I'm assuming there might be critical data in your DB. If your DB contains any serious data, I would recommend you learn how to write a secure web front end before you consider accessing it from your iPhone app, or you could open up your data to unscrupulous users. Or, even better, have someone who knows how to write a secure webservice make one for you to access.

    On the other hand, if your DB contains game high scores, go look in the tutorial section for how to access high scores from PHP.

    BTW, JDBC is a technology your web server would use to access the database. You will still need a webserver like Apache.
  15. macrumors newbie

    So what about internal connections?

    So what about internal connections to oracle? For instance an app that can only connect to the DB if it is connected to the secure intranet WIFI in your office? Example - collecting inventory data to be compared to the existing data. Or, entering product data from production lines. I'm thinking iPad.

Share This Page