Hello,

I am trying to get OCILib (http://orclib.sourceforge.net/), a free Oracle 
library, running on MacOSX. I have built the library from source and 
successfully run a test class via the terminal containing the example code in 
the OCILib documentation. As an experiment I have created a Cocoa app in XCode 
and dumped the code in the test class in the App delegate's 
applicationDidFinishLaunching method.

However when I run the app from within XCode I get the following error:

ORA-12170: TNS:Connect timeout occurred

Has anyone tried anything similar or seen a similar problem?

Oracle 10 XE running on a CentOS 5.5 VM in VMWare Fusion

I know the DB is up and running since I can connect to it using DBVisualizer 
and my command line tool runs fine.
I have tried turning off the firewall on both the MacOSX and CentOS but to no 
avail.
I have also tried su to the admin user and then running XCode from the terminal 
as root with sudo open <path to XCode executable>
Via printfs I know the initialize call is working.

Here is the code:

- (void) applicationDidFinishLaunching: (NSNotification *) aNotification
{
        printf ("--> A\n");

        OCI_Connection* cn;
        OCI_Statement* st;
        OCI_Resultset* rs;

        if (!OCI_Initialize (NULL, NULL, OCI_ENV_CONTEXT))
        {
                OCI_Error *error = OCI_GetLastError();
                printf ("--> Initialize failed: code = %d, msg = %s\n", 
OCI_ErrorGetOCICode (error), OCI_ErrorGetString (error));
                OCI_Cleanup();
                return;
        }

        printf ("--> B\n");

        cn = OCI_ConnectionCreate ("xe", "ddi", "kitty", OCI_SESSION_DEFAULT);
        if (cn == NULL)
        {
                OCI_Error *error = OCI_GetLastError();
                printf ("--> Create connection failed: code = %d, msg = %s\n", 
OCI_ErrorGetOCICode (error), OCI_ErrorGetString (error));
                OCI_Cleanup();
                return;         
        }

        printf (OCI_GetVersionServer(cn));

        st = OCI_StatementCreate (cn);
        if (st == NULL)
        {
                OCI_Error *error = OCI_GetLastError();
                printf ("--> Create statement failed: code = %d, msg = %s\n", 
OCI_ErrorGetOCICode (error), OCI_ErrorGetString (error));
                OCI_Cleanup();
                return;         
        }

        OCI_ExecuteStmt (st, "select count(*) from location");
        rs = OCI_GetResultset (st);
        while (OCI_FetchNext (rs))
        {
                printf ("Locations = %d\n", OCI_GetInt (rs, 1));
        }

        OCI_Cleanup();
}

So the create connection step is failing. I can see the main thread waiting for 
the connection as I get the spinning color wheel cursor. It times out after 
about 30-45 seconds. Running the same code in a simple .c file runs instantly.

Any help appreciated.


Thanks.

Tim Mowlem_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to