8 Replies Latest reply: Mar 16, 2010 8:34 AM by jgehrke RSS

    connecting to Oracle db server using Mac and Objective C

    606239
      Hi,

      I am not sure if this is the correct forum to post my query - and hope to get some response here.
      I have a Oracle server set up on a remote computer somewhere. I have the username, passwd and the connection string for the same.

      I need to connect to this DB using a Mac OS X laptop, from a code written in Objective-C. I am not sure how to go about it.

      I know that there is something called OCI to connect from Windows/Linux platform using C/C++ code - and ODBC which servers as some kind of interface between Oracle and my client system - but I wanted to know wha might be a better/quicker approach on Mac and Objective-C since I am new to both.

      I'd deeply appreciate any help here.

      Thanks,
      Priyanka.
        • 1. Re: connecting to Oracle db server using Mac and Objective C
          322957
          If you have a Mac Intel (Mac Pr, Mac Book, Mac Book Pro) there is no way at the moment.
          The Oracle 10.2 Client (and Server) for Mac Intel is expected on 2nd Half of 2008.
          The current PowerPC 10.1 Client doesn't run under Rosetta (emulation mode) on a Mac Intel.

          If ou have a previous Mac (G4 or G5, PowerMac or PowerBook)
          you must download the full Oracle 10.1.0.3 Client for Apple PowerPC
          and install it, you can follow instructions here:
          http://download.oracle.com/docs/html/B13955_01/toc.htm
          http://download.oracle.com/docs/html/B13956_01/toc.htm
          Download also the 10.1 manuals (those of the Developer section):
          http://www.oracle.com/pls/db10g/portal.portal_demo3?selected=5.
          Please note that Os X 10.4 is now supported for Oracle 10.1.0.5 Server
          and many people use Oracle 10.1.0.3 Server or Client on Os X 10.4 client.

          There have been other (very old) posts into this Forum, whith additional info useful to you:
          Re: error when including xmlrpc header file in proC program
          Re: proc and xcode 2
          Re: Newbie to Oracle
          Re: cocoa developers ?
          Re: osx : sqlca.h is crushed at install
          10g Signal Handlers and Dynamic Binding Problems on Mac OS X
          Linking OCI libraries with Cocoa in Project Builder (MAC OS 10.2)
          Do yourself a search using "objective", "proc", "sqlca", for example.

          I never wrote a complete Obj-C program,
          but I wrote some C programs (no GUI, just Terminal applications)
          on a PowerBook G4 (Os X 10.3, XCode 1.5, Oracle Client 10.1.0.3) using Pro*C.


          As a rule Oracle provides the following technologies:
          1- OCI / OCCI
          This is low-level programming. You must write a lot of C code in order to write
          just a single SQL statement and process the result. Yet it's very efficient and you have
          complete control of all the features of the Oracle database you connect to.
          You need a few Oracle libraries, which are usually shipped inside the Oracle Client stuff.
          You will write C (or C++) programs, specify the locations of Oracle OCI (or OCCI) header files
          and then link the oracle OCI (or OCCI) libraries at compile time.
          ORACLE_HOME=/Users/oracle/10.1/db
          -L$(ORACLE_HOME)/lib -L$(ORACLE_HOME)/rdbms/lib
          At runtime you will specify the locations of Oracle runtime libraries (using environment variables)
          and your program will use Oracle shared dynamic libraries.
          DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$ORACLE_HOME/lib;$ORACLE_HOME/rdbms/lib
          More info inside the manuals:
          "Oracle Call Interface Programmer's Guide"
          "Oracle C++ Call Interface Programmer's Guide"
          There are a few open source projects which already has wrapped low-level OCI functionalities
          into higher level functions (so that you write simpler code but still use the powerful OCI code):
          http://sourceforge.net/search/?type_of_search=soft&words=Oracle+OCI

          2- Pro*C / Pro*C++
          This is a higher level programming. You write standard SQL commands inside a "SQL Section"
          and then process your source file by an Oracle precompiler,
          which will translate those SQL commands into C code for you.
          You still need a few Oracle libraries (shipped inside the Oracle Client stuff) and must specify the
          locations of Pro*C header files, then you link Pro*C libraries at compile time.
          ORACLE_HOME=/Users/oracle/10.1/db
          -L$(ORACLE_HOME)/lib -L$(ORACLE_HOME)/rdbms/lib
          At runtime you will specify the locations of Oracle runtime libraries (using environment variables)
          and your program will use Oracle shared dynamic libraries.
          DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$ORACLE_HOME/lib;$ORACLE_HOME/rdbms/lib
          More info inside the manuals:
          "Pro*C/C++ Precompiler Programmer's Guide"
          "Programmer's Guide to the Oracle Precompilers"

          3- Java and JDBC
          Oracle has a strong support for Java and JDBC connections (both Thin and Thick drivers exists).
          You might be interested into a Obj-C application linked to a small Java section that connect to the db.
          More info inside the manuals:
          "Java Developer's Guide"
          "JDBC Developer's Guide and Reference"

          Oscar
          • 2. Re: connecting to Oracle db server using Mac and Objective C
            431839
            I have written a complete application in Cocoa, using Objective-C and JDBC. I have more information in this if you are interested using JDBC.

            Ivan
            • 3. Re: connecting to Oracle db server using Mac and Objective C
              293759
              I would love to get some info on Oracle Objective-C and JDBC.
              I am running Leopard on a Mac Intel, though.

              TIA

              Jener
              • 4. Re: connecting to Oracle db server using Mac and Objective C
                431839
                JDBC is Java, and therefore platform neutral. It doesn't matter if the server software is running on Windows, Linux or whatever. The client software uses JDBC to communicate between the server and client. Running on intel is fine.
                • 5. Re: connecting to Oracle db server using Mac and Objective C
                  606239
                  Hi,
                  As u mentioned, Java is neutral and so should be fine..I am definitely interested in knowing more about this - can you send me further details about the code or so?

                  Thanks,
                  Priyanka.
                  • 6. Re: connecting to Oracle db server using Mac and Objective C
                    386814
                    I have written java programs using jdbc that run on the Intel Macbook to talk to Oracle 10.2 running on windows and unix servers - that works well.

                    I can post details if you need them.

                    Paul
                    • 7. Re: connecting to Oracle db server using Mac and Objective C
                      760106
                      Tell me how to create Cocoa application with any Oracle connector. I'm try work with occi, but it's only for c++ and can't work (for me) in Cocoa application (based on Objective-C)
                      • 8. Re: connecting to Oracle db server using Mac and Objective C
                        jgehrke
                        Hi,
                        Objective-C, C++ and C are all processed by the same compiler on a Mac's native development environment.
                        There is a documented and supported way to take over data and control from Objective-C to C++.
                        Using C is a bit easer btw., if you are used to use C.
                        Both ways you may use to call either OCI or OCCI within a native Cocoa app.
                        If you're using XCode, have a search for "Using C++ With Objective-C" in the documentation, "Mixing Objective-C and C++ Language Features" in detail.
                        Jens