• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Problem connecting to Oracle with app run from XCode
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem connecting to Oracle with app run from XCode


  • Subject: Problem connecting to Oracle with app run from XCode
  • From: Timothy Mowlem <email@hidden>
  • Date: Wed, 6 Oct 2010 00:07:31 +0100

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@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Problem connecting to Oracle with app run from XCode
      • From: Francis Devereux <email@hidden>
  • Prev by Date: Re: NSOutlineView multi cell type binding query
  • Next by Date: Re: NSOutlineView multi cell type binding query
  • Previous by thread: Re: NSImage is Caching
  • Next by thread: Re: Problem connecting to Oracle with app run from XCode
  • Index(es):
    • Date
    • Thread