dotConnect for Oracle, like most of applications that work with Oracle, uses Oracle Call Interface (OCI) to connect to Oracle database server. This is usual way to develop Oracle applications with a third-generation language. However, it requires Oracle Client software installed on workstation that is the cause of additional expenses for installation and administration. Moreover, .NET security settings may restrict usage of unmanaged libraries, which makes impossible to use the client software, for example, on ASP.NET servers. Starting with dotConnect for Oracle 3.0, these problems can be eliminated by using the Direct mode of connecting to server.
In the Direct mode dotConnect for Oracle connects to an Oracle server directly, without calling any third party libraries. It allows your application to work with Oracle directly through TCP/IP protocol without involving the Oracle Client software. To run your application built with dotConnect for Oracle you only need to have operating system with TCP/IP protocol support.
Connection String Options in Direct Mode
Connecting to Oracle servers in the Direct mode is as easy as through OCI. You must know the address of computer where Oracle server is, port number to connect, and database global system identifier. The OracleConnection.ConnectionString property must include the following fragments:
|Direct*||Whether to use Direct mode||Direct=true|
|Data Source (or Host, or Server)||Oracle server's IP address or DNS name||Data Source=192.168.0.1|
|Port||Port number to connect to||Port=1521|
|SID||System identifier (Global Database Name)||SID=orcl|
* Mobile Edition works only in Direct mode, and there are no such parameter for it.
The whole connection string may look as follows: "User Id=Scott;Password=tiger;Direct=true;Data Source=192.168.0.1;Port=1521;SID=orcl".
using Devart.Data.Oracle; ... OracleConnectionStringBuilder oraCSB = new OracleConnectionStringBuilder(); oraCSB.Direct = true; oraCSB.Server = "192.168.0.1"; oraCSB.Port = 1521; oraCSB.Sid = "orcl"; oraCSB.UserId = "scott"; oraCSB.Password = "tiger"; OracleConnection myConnection = new OracleConnection(oraCSB.ConnectionString); myConnection.Open();
|Visual Basic||Copy Code|
Imports Devart.Data.Oracle ... Dim oraCSB As OracleConnectionStringBuilder = New OracleConnectionStringBuilder oraCSB.Direct = true oraCSB.Server = "192.168.0.1" oraCSB.Port = 1521 oraCSB.Sid = "orcl" oraCSB.UserId = "scott" oraCSB.Password = "tiger" Dim myConnection As OracleConnection = New OracleConnection(oraCSB.ConnectionString) myConnection.Open()
The only option of listed above (except for Direct) that has the default value is Port. Port number defaults to 1521 (most commonly used in Oracle databases). Thus you can omit this option in the connection string.
You can connect to Multi-Threaded Server using the Direct mode. The server must be configured to use the specific port and TTC protocol. This can help you avoid firewall conflicts.
Note that when Direct is false (by default), the Data Source option has another meaning: you must specify either a TNS name or a TNS description. The Port and SID options are not allowed when Direct is false.
How to Switch to Direct Mode
Changing connection strings is the only action required to switch an application to the Direct mode. You do not have to rewrite other parts of your application. You can return to using OCI at any moment later reversing the changes made to connection strings.
Oracle Advanced Security Support in Direct Mode
dotConnect for Oracle supports Oracle Advanced Security data encryption and data integrity in the Direct mode and can connect to Oracle Database as a Service (DBaaS).
In the OCI mode, data encryption and integrity are configured in Oracle Client, and dotConnect for Oracle settings does not affect them. In the Direct mode you can configure the data encryption and integrity by using the corresponding properties of the DirectUtils class.
Data Encryption is an Oracle Advanced Security service that encrypts message data between client and server. dotConnect for Oracle enables data encryption in the Direct mode depending on the DirectUtils.EncryptionLevel property.
Please note that standard DES (56-bit key size) and DES40 (40-bit key size) encryption is not supported in the Direct mode, because these encryption kinds cannot be considered secure enough.
Data integrity is an Oracle Advanced Security service that ensures that the data, transmitted between client and server, is not modified in between and is not retransmitted multiple times by an attacker. dotConnect for Oracle enables data integrity in the Direct mode depending on the DirectUtils.DataIntegrityLevel property.
For the information on the possible values of these properties, and how they enable or disable encryption, see SecurityLevel
Default value for both of these properties is SecurityLevel.Accepted, which corresponds to the default behavior of Oracle Client. Usually, you don't need to modify this value. You can keep default value for connecting to Oracle Data Cloud in the Direct mode.
RAC Support in Direct Mode
While the OCI Mode fully supports RAC, Failover, Load Balancing, the Direct Mode supports RAC with Connect Time Connection Failover (CTCF) only. In order to use RAC support in the Direct mode, you need to specify the Server connection string parameter in a format like in the tnsnames.ora file. For example:
using Devart.Data.Oracle; ... OracleConnection conn = new OracleConnection("Server=(DESCRIPTION = "+ " (ADDRESS = (PROTOCOL = TCP)(HOST = db)(PORT = 1521))" + " (ADDRESS = (PROTOCOL = TCP)(HOST = dboracle)(PORT = 1520))" + " (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.9)(PORT = 1521))" + " (CONNECT_DATA =" + " (SERVER = DEDICATED)" + " (SERVICE_NAME = orcl1120)" + " )" + " );" + "direct=true;uid=system;pwd=manager");
|Visual Basic||Copy Code|
Imports Devart.Data.Oracle ... Dim conn As New OracleConnection("Server=(DESCRIPTION = " + _ " (ADDRESS = (PROTOCOL = TCP)(HOST = db)(PORT = 1521))" + _ " (ADDRESS = (PROTOCOL = TCP)(HOST = dboracle)(PORT = 1520))" + _ " (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.9)(PORT = 1521))" + _ " (CONNECT_DATA =" + " (SERVER = DEDICATED)" + _ " (SERVICE_NAME = orcl1120)" + " )" + " );" + _ "direct=true;uid=system;pwd=manager")
Direct Mode Compared to OCI Mode
Applications compiled with and without the Direct mode have similar size and performance. Security of using the Direct mode doesn't differ from using OCI.
The advantages of the Direct mode are:
- installation and administration of Oracle Client software is not required;
- system requirements are reduced.
The Direct mode has some limitations:
- Connect using the TCP/IP protocol only.
- Oracle TimesTen is not supported.
- While the OCI Mode fully supports RAC, Failover, Load Balancing, the Direct Mode supports RAC with Connect Time Connection Failover (CTCF) only.
- The OracleLoader class uses Array Binding instead of the direct path load interface in the Direct mode, and has limited functionality.
- Please note that we don't guarantee dotConnect for Oracle compatibility in the Direct mode with all Oracle servers and in every network. We have tested it with all versions of Oracle server for Windows and Linux since 7.3 in local network. Other platforms may cause some incompatibility issues.
- The Direct mode does not support NLS conversion on client side.
- The Direct mode does not support connecting using OracleCredential.
- Transparent Application Failover not supported
- Statement caching is not available.
- Proxy authentication features are not available.
- LDAP authentication is not supported in the Direct mode.
- Passing sharding key values when connecting for performing single-shard queries to a sharded database is not supported in the Direct mode.
- Implicitly returned resultsets (via DBMS_SQL.RETURN_RESULT introduced in Oracle 12c) are not supported.
- Oracle Transaction Guard is not supported.
- The OracleDatabase class is not supported in the Direct mode.
- The OracleConnection.PurgeStatementCache method works only in OCI mode.
- The OracleConnection.HAEvent is supported only in the OCI mode and only for Oracle Client 10g and higher.
- A number of OracleXml properties and methods are not supported in the Direct mode. See the property descriptions to determine whether they are supported in the Direct mode.
- AsyncNotification in Advanced Queuing is not supported in the Direct mode.
You can return to connecting through OCI at any time if restrictions above become critical for you.