Connect to Oracle Server (FireDAC)
Go Up to Database Connectivity (FireDAC)
This topic describes how to connect to Oracle Server.
The FireDAC native driver supports Oracle Enterprise, Standard (ex Workgroup), and Express (ex Personal) server editions version 8.0.3 and later. For detailed discussion on Oracle usage in FireDAC for the Delphi application, read the "Using Oracle with FireDAC" chapter.
Windows Client Software
FireDAC requires one of the following Oracle x86 or x64 client software types to be installed on the workstation:
- "Fat" Oracle Client (details) -- It requires the standard install procedure. The driver uses the client that is installed in the primary Oracle Home, if not specified explicitly.
- "Thin" Oracle Instant Client (details) -- The driver uses the client, which is either copied into a folder in the PATH or into the application EXE folder, if not specified explicitly. See "Using Instant Client" below.
If the Oracle client software has not been installed properly, an exception is raised when trying to connect:
Using Instant Client
To install Instant Client, download the Oracle Instant x86 or x64 client archive, unpack it and copy the files:
in your application EXE folder or in a folder in the PATH.
When you are using TNS names, put the tnsnames.ora file in the same folder or set the TFDPhysOracleDriverLink.TNSAdmin property value to a folder path with tnsnames.ora or use the TNSAdmin driver configuration parameter.
Set TFDPhysOracleDriverLink.NLSLang to the required value or use the NLSLang driver configuration parameter.
OS X Client Software
- the libclntsh.dylib x86 client library.
You can download it as Instant Client for OS X (here)
To install on Linux, read the following articles:
- Instant Client Installation - for basic Oracle Instant Client installation steps;
- SQL*Plus Instant Client - for advanced Oracle Instant Client configuration, including configuring language and TNS parameters.
To link the driver:
- Drop a TFDPhysOracleDriverLink component from the "FireDAC Links" palette page.
- Or include the FireDAC.Phys.Oracle unit in an uses clause.
Connection Definition Parameters
To connect to an Oracle DBMS, most applications require that you specify DriverID, Database, User_Name, and Password (see Defining Connection (FireDAC) for details).
The value can be one of the following:
|OSAuthent||Specify Yes to use OS authentification, and No to use the DBMS authentification.||No|
|User_Name||The Oracle user name, if OSAuthent=No||Scott|
|Password||The Oracle user password, if OSAuthent=No||tiger|
The Oracle authentification mode:
|ReadTimeout|| Specifies the timeout value in milliseconds for the receive or read operations.
Specifying zero means no timeout.
|WriteTimeout|| Specifies the timeout value in milliseconds for the database server to complete a send operation to clients.
Specifying zero means no timeout.
|CharacterSet||The character set for the connection. If not specified, the NLS_LANG variable value is used.||
Defines how to represent Boolean values:
|ApplicationName||Name of the application. If specified, this value is stored in the V$SESSION column MODULE.||AllBooks|
|OracleAdvanced||Additional Oracle session options. For details, see the ALTER SESSION SET chapter, the "Initialization Parameters and ALTER SESSION" paragraph. A value format is - <option>=<value>[;...].|
|NewPassword||Specifies the new Oracle user password. FireDAC connects to the DB using the old password and immediately changes it to the new one.||tiger2|
|MetaDefSchema||Specifies the default schema for the application. The design time code omits the schema name in object names if it is equal to MetaDefSchema.||SCOTT|
- Connect to a database using the predefined TNS name (stored in tnsnames.ora):
DriverID=Ora Database=ORA_920_APP User_Name=ADDemo Password=a
- Connect to a database using host, port, and instance name info:
DriverID=Ora Database=(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = OraSrv)(PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = orcl))) User_Name=ADDemo Password=a
- Connect to a local database as sysdba:
DriverID=Ora User_Name=sys AuthMode=sysdba
- Connect to a database using the TNS name and change the password:
DriverID=Ora Database=ORA_920_APP User_Name=ADDemo Password=a NewPassword=b
- Connect to a database using the easy connect string:
DriverID=Ora Database=OraSrv:1521/orcl User_Name=ADDemo Password=a