dotConnect for Oracle Documentation
In This Topic
    Using Direct Mode
    In This Topic

    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:

    Option Name Description Example
    Direct* Whether to use Direct mode Direct=true
    Data Source (or Host, or Server) Oracle server's IP address or DNS name Data Source=
    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=;Port=1521;SID=orcl".

    using Devart.Data.Oracle;
    OracleConnectionStringBuilder oraCSB = new OracleConnectionStringBuilder();
    oraCSB.Direct = true;
    oraCSB.Server = "";
    oraCSB.Port = 1521;
    oraCSB.Sid = "orcl";
    oraCSB.UserId = "scott";
    oraCSB.Password = "tiger";
    OracleConnection myConnection = new OracleConnection(oraCSB.ConnectionString);
    Imports Devart.Data.Oracle
    Dim oraCSB As OracleConnectionStringBuilder = New OracleConnectionStringBuilder
    oraCSB.Direct = true
    oraCSB.Server = ""
    oraCSB.Port = 1521
    oraCSB.Sid = "orcl"
    oraCSB.UserId = "scott"
    oraCSB.Password = "tiger"
    Dim myConnection As OracleConnection = New OracleConnection(oraCSB.ConnectionString)

    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 = = 1521))" +
                                                       "        (CONNECT_DATA =" +
                                                       "         (SERVER = DEDICATED)" +
                                                       "         (SERVICE_NAME = orcl1120)" +
                                                       "        )" +
                                                       "       );" +
    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 = = 1521))" + _
                                             "        (CONNECT_DATA =" + "         (SERVER = DEDICATED)" + _
                                             "         (SERVICE_NAME = orcl1120)" + "        )" + "       );" + _

    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:

    The Direct mode has some limitations:

    You can return to connecting through OCI at any time if restrictions above become critical for you.

    See Also

    Logging Onto The Server  | SSL/TLS Support in Direct Mode  | SSH Support in Direct Mode