How to connect to Oracle DB from Ubuntu Linux.

Posted by on in Programming

How to connect to Oracle DB using Delphi FireDAC.

Delphi uses Linux(64). and Linux is ubuntu.

I used "Oracle SE One" of AWS(RDS).


[Instant Client download]

Download 12.2 Instant Client.

I downloaded


Unpack it after placing it on Linux. 


Create a directory and place the decompressed file.

 instantclient_12_2 directory is made.

mkdir /opt/oracle
mv instantclient_12_2 /opt/oracle/

Move this to the directory created.

Create a link.

ln -s
ln -s


Setting environment variables.

export LD_LIBRARY_PATH=/opt/oracle/instantclient_12_2:$LD_LIBRARY_PATH
export PATH=/opt/oracle/instantclient_12_2:$PATH


At this point, Instant Client configuration is complete.

Finally, "./PAServer-19.0/paserver" is started up and ready.



[Create a new project.]

In Delphi IDE side, create a new project. Web Server Application, check Linux.

I chose "stand-alone console application" this time.

Place some components on TWebModule1.

TFDConnection, TFDPhysOracleDriverLink, TFDQuery, TFDStanStorageJSONLink

Return the contents acquired by FDQuery1 with JSON. Write the code.

There is a simple table and some records on DB side.

procedure TWebModule1.WebModule1DefaultHandlerAction(Sender: TObject;
  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
  ms_:  TMemoryStream;
  FDQuery1.Active := True;
  ms_ := TMemoryStream.Create;
  FDQuery1.SaveToStream(ms_, TFDStorageFormat.sfJSON);
  ms_.Position  := 0;
  Response.ContentStream  := ms_;

procedure TWebModule1.WebModuleCreate(Sender: TObject);
  FDPhysOracleDriverLink1.VendorLib   := '/opt/oracle/instantclient_12_2/';
  FDConnection1.Connected := True;


When executing debugging, the following option is mandatory.

"/usr/bin/xterm -e "%debuggee%""




[In case of failure.]

Project raised exception class EFDException with message '[FireDAC][Phys][Ora]-314. Cannot load vendor library []. Hint: check it is in the PATH or application EXE directories, and has x64 bitness.'.

Failure Review the environment on the Linux side.


[In case of success.]


The content saved by JSON of FDQuery1 is displayed.






Gold User, No rank,
Delphi / C++Builder blogger


Check out more tips and tricks in this development video: