Search code examples
macosoracle-databasedelphifiremonkeyfiredac

Connecting to an remote Oracle XE11 database using FireDac and OSX Mavericks


I made a small application that should connect to an remote Oracle database running inside a virutal machine (W8.1).

On a sucessfull connection a showmessage should popup.

I folled those steps to ensure my application is able to connect: installing Oracle Instantclient on Mac OS/X without setting environment variables?

The application uses FireDac's Oracle FireDAC.Phys.Oracle driver to connect and TFDGUIxLoginDialog to login.

guianderror

Nothing really special indeed:

procedure TForm1.Button1Click(Sender: TObject);
begin
  FDConnection1.Connected := True;
end;

procedure TForm1.FDConnection1AfterConnect(Sender: TObject);
begin
  ShowMessage('Connected');
end;

procedure TForm1.FDConnection1Error(ASender: TObject;
  const AInitiator: IFDStanObject; var AException: Exception);
begin
  ShowMessage(AException.ToString);
end;

This is working fine and quick in Windows 8.1 and 10.

However in Mavericks i get the OID generation failed error as shown in the picture.

It doesn't matter if i use the VMs IP or DNS name to connect. It won't connect at all.

Oracle's SQL Developer is able to connect, tho.

The Oralce SQL Developer takes about 15 - 20s until it establishes a connection to the database.

My application isn't even trying that long to connect. It fails after ~7s.

Maybe it times out before a stable connection is available?

If so, is there any way to extend the login process time before throwing errors?

Or maybe this is a complete other problem?

Please note that i spent about 5 hours figuring out this problem already without success.

Any help is greatly appreciated.


Solution

  • Ok here is what went wrong.

    The host file of my OSX Mavericks guest system was incorrect.

    Like @whosrdaddy posted you have to change your host file like explained in this link: http://chaos667.tumblr.com/post/20006357466/ora-21561-and-oracle-instant-client-11-2

    I did enter the Devicename one can find in Sharing -> Devicename in the OSX Control Panel.

    osx control panel devicename

    So what i did was entering this name in the host file.

    osx hostfile

    However i was using the incorrect name.

    I got the correct name by using echo "127.0.0.1 $(hostname) which printed the correct name: 127.0.0.1 LionVM.local.

    I didn't use this VM in a long time and probably forgotten that i renamed the devicename after upgrading to Mavericks some time ago.

    Now my application is able to connect.