dotConnect Universal Documentation
In This Topic
    Using dotConnect Universal with dotConnect for Oracle
    In This Topic

    If you need to choose which data provider for Oracle to use with dotConnect Universal, we recommend using dotConnect for Oracle because of its obvious advantages. This article provides a brief overview of dotConnect for Oracle, describes some useful features and helps you get started quickly.

    Overview

    dotConnect for Oracle is a full-featured 100% managed ADO.NET data provider for the .NET Framework. dotConnect for Oracle is acknowledged as the leading ADO.NET data provider for Oracle, and it has many advantages over any rival product. The main features of dotConnect for Oracle are:

    The full list of dotConnect for Oracle features can be found on the product page.

    Developer Edition of dotConnect Universal includes dotConnect for Oracle as a bundled provider. The Trial Edition includes trial dotConnect for Oracle Data Provider as well. For Express Edition of dotConnect Universal, dotConnect for Oracle Data Provider should be purchased and installed separately.

    Compatibility

    dotConnect Universal is compatible with dotConnect for Oracle version 5.00 and above.

    Deployment

    To deploy applications written with dotConnect Universal, copy the run-time assemblies Devart.Data.Universal.dll and Devart.Data.Universal.Oracle.dll to target machine. If you are using the standalone (not bundled) dotConnect for Oracle Data Provider, you will also have to deploy its Devart.Data.Oracle.dll assembly.

    These assemblies can be registered at the Global Assembly Cache (GAC) for the appropriate .NET Framework or placed in the folder of your application.

    For web projects, you may also need to deploy the Devart.Data.Universal.Web.dll, Devart.Data.Oracle.Web.dll and App_Licenses.dll assemblies. The *.Web.dll assemblies are required for using the ASP.NET Provider Model, and the App_Licenses.dll assembly is a part of licensing mechanism.

    Web projects are usually run as partially trusted code. The following permissions are required by dotConnect Universal and dotConnect for Oracle:

    Connection String

    Suppose you want to connect in OCI mode to an Oracle server with TNS name oraserver, with the user name scott and the password tiger. In this case your connection string would look like this:

    Provider=Oracle;data source=oraserver;user=scott;password=tiger

    Suppose you want to connect in Direct mode to an Oracle server running on the host 192.168.0.1, with system identifier orcl, and the port to connect is 1251. In the Direct mode the meaning of the Data Source parameter is different. It determines IP address or host name of the server. The whole connection string looks as follows:

    Provider=Oracle;direct=true;data source=192.168.0.1;port=1521;sid=orcl;user=scott;password=tiger

    The following table enumerates most important connection string parameters.

    Name Description
    ClientId Specifies the client identifier for the connection.
    Connect Mode Allows to open a session with administrative privileges SYSDBA or SYSOPER.
    Connection Class Specifies the connection class used for Oracle's Database Resident Connection Pooling (DRCP). Requires the Oci Session Pooling parameter to be set to true. DRCP is supported starting with Oracle 11g.
    Connection Lifetime Specifies the maximum lifetime (in seconds) of a pooled connection. When a connection is returned to the pool, its creation time is compared with the current time, and the connection is destroyed if that time span exceeds the value specified by Connection Lifetime. The default value is 0.
    Connection Timeout Specifies the time (in seconds) to wait while trying to establish a connection before terminating the attempt and generating an error. A value of 0 indicates no limit. The default value is 15 seconds.
    Data Source -or- Server -or- Host Specifies the name of TNS alias of Oracle database to which to connect. For more information refer to Server property.
    Default Command Timeout Specifies the time (in seconds) to wait while trying to execute a command before terminating the attempt and generating an error. A value of 0 indicates no limit.
    Default Fetch Size Specifies the default number of rows fetched from the server in a single round-trip for commands created on the connection.
    Describe Stored Procedure Enables or disables additional check queries performed when executing a command whose CommandType is set to StoredProcedure.
    Direct Enables dotConnect for Oracle Data Provider to operate without an Oracle client installed when set to true. The default value is false.
    Enlist Determines whether the connection is automatically enlisted in the current distributed transaction. The default value is true.
    HA Events Allows dotConnect for Oracle Data Provider to proactively remove connections to the corresponding Oracle database service, service member, instance, or node from the pool when it goes down.
    Home Specifies the Oracle Home that will be used.
    Initialization Command Specifies a database-specific command that should be executed immediately after establishing the connection. You can specify a sequence of several commands in this parameter.
    Lob Block Size Specifies the size (in megabytes) of a block used to read/write CLOB or NCLOB data from/to the database. Supported in OCI mode only. The default value is 0, which means the whole value is sent in one block.
    Max Pool Size Specifies the maximum number of connections allowed in the pool. Setting the Max Pool Size value of the ConnectionString can affect performance. The default value is 100.
    Min Pool Size Specifies the minimum number of connections allowed in the pool. The default value is 0.
    Number Mappings Specifies custom mappings used to convert Oracle NUMBER values to .NET types, based on precision and scale.
    Oci Session Pool Allow Waiting Determines whether new connections wait for an existing one to close when Oci Session Pool Max Size is reached; otherwise, an exception is thrown.
    Oci Session Pool Connection Lifetime Specifies the lifetime of a session (in seconds) in the OCI session pool. If the connection's lifetime exceeds this value when it is returned to the pool, it is closed and disposed. A value of 0 means the lifetime is never checked.
    Oci Session Pool Increment Specifies the number of new sessions to start when the current number of sessions in the pool is less than Oci Session Pool Max Size. Valid values are 1 or greater.
    Oci Session Pool Max Size Specifies the maximum number of sessions that can be opened in the OCI session pool. When this limit is reached, no additional sessions can be opened. Valid values are 1 or greater.
    Oci Session Pool Min Size Specifies the minimum number of sessions kept in the OCI session pool. This number of sessions is started initially; after that, sessions are opened only when necessary.
    Oci Session Pool Password Specifies the password for the proxy user. Used only when Oci Session Pooling is enabled.
    Oci Session Pool User Id Specifies the user name for the proxy user. Used only when Oci Session Pooling is enabled.
    Oci Session Pooling Enables the OCI Session Pooling feature when set to true. In this mode, the built-in dotConnect for Oracle connection pool is disabled.
    OraMts Enables the use of Oracle Services for Microsoft Transaction Server (OraMTS) for distributed transactions when set to true.
    Pass Parameters By Name Passes parameters by name to stored procedure calls, regardless of individual command settings, when set to true. The default value is false.
    Password Specifies the password for the Oracle login account. Leave blank if you want to use Integrated Security connections (OS authentication).
    Persist Security Info Determines whether security-sensitive information, such as the password, is retained in the connection string after the connection has been opened.
    Pooling Determines whether, by default, the UniConnection object is drawn from the appropriate pool or is created and added to the appropriate pool. The default value is true.
    Port Specifies the number of a port to communicate with listener on the server to use in Direct mode. The default value is 1521.
    Proxy Password Specifies the password used to authenticate with the proxy server.
    Proxy User Id Specifies the account name used to authenticate with the proxy server.
    Run Once Command Specifies a database-specific command that should be executed immediately after establishing the connection. Unlike Initialization Command, it is not executed for connections obtained from the connection pool.
    SID -or- Service Name Specifies the name of listener service running on the server to use in Direct mode. The default value is empty string.
    SSH Authentication Type Specifies the client authentication method used to establish the SSH connection.
    SSH Cipher List Specifies the list of ciphers that the client agrees to use for the SSH connection.
    SSH Host Specifies the name or IP address of the SSH server.
    SSH Host Key Specifies the location of the public key, on the client side, used to verify the server host key while establishing the connection.
    SSH KeyExchange Algorithms Specifies the algorithms used to securely establish a shared encryption key between the client and the server.
    SSH MAC Algorithms Specifies the algorithms used to verify the integrity and authenticity of data exchanged between the client and the server.
    SSH Passphrase Specifies the passphrase for the client key.
    SSH Password Specifies the user password on the SSH server.
    SSH Port Specifies the number of the port on the SSH server to connect to. The default value is 22.
    SSH Private Key Specifies the location of the private key to use for the SSH connection.
    SSH Strict Host Key Checking Indicates whether the server host key is verified while establishing the connection. The default value is false.
    SSH User Specifies the user identifier on the SSH server.
    SSL Cert Specifies the SSL certificate, provided as a Base64 string.
    SSL Key Specifies the SSL private key required to enable secure TLS/SSL connections.
    SSL ServerCertDN Specifies parameters used for the server certificate check.
    SSL WalletPath Specifies the location of the Oracle Wallet used to get a certificate for connecting to Oracle in Direct mode.
    Statement Cache Purge Determines whether to clear the OCI statement cache when closing the connection or returning it to the pool. The default value is false.
    Statement Cache Size Enables statement caching and specifies the maximum number of statements that can be cached for a connection. The default value is 0 (disabled).
    Transaction Scope Local Restricts all connections within a TransactionScope object to a single internal connection when several connections use the same connection string. The default value is false.
    Trim Fixed Char Specifies whether to trim trailing spaces when reading data from fixed-length string data types (CHAR, NCHAR). The default value is true.
    Unicode Specifies whether the dotConnect for Oracle Data Provider uses UTF16 mode API calls. The default value is false.
    Use Performance Monitor Enables performance counters that allow you to measure connection statistics, such as the number of active and pooled connections, via Windows Performance Monitor or programmatically.
    User ID -or- User Specifies the Oracle login account. Leave blank if you want to use Integrated Security connections (OS authentication).
    Validate Connection Specifies whether to validate connections that are retrieved from the pool.

    Quick Start Steps

    To get up and running quickly, you have to perform the following steps:

    1. Embed licensing information into your application. If you use bundled dotConnect for Oracle version, you need only dotConnect Universal licensing. If you use a standalone dotConnect for Oracle installation, embed the licensing information about both dotConnect Universal and dotConnect for Oracle data providers. For more details on licensing refer to the Licensing article. For bundled providers it may be enough to drop a UniConnection component onto a form designer to embed the licensing information.
    2. Create a UniConnection object.
    3. Set the ConnectionString property of the UniConnection object to a string containing the part Provider=Oracle.
    4. Create a UniCommand object and link it to the UniConnection object.
    5. Open the connection.

    That's all you need to start executing queries on the server. Below is a code fragment that illustrates steps 2-5. It also shows how to perform INSERT and SELECT operations.

    UniConnection connection = new UniConnection("Provider=Oracle;direct=true;data source=192.168.0.1;port=1521;sid=orcl;user=scott;password=tiger");
    try {
      UniCommand cmd = connection.CreateCommand();
      cmd.CommandText = "INSERT INTO dept (DeptNo, Dname, Loc) VALUES (:DeptNo, :DName, :Loc)";
      UniParameter parameter = cmd.Parameters.Add("DeptNo", UniDbType.Int);
      parameter.Value = 150;
      parameter = cmd.Parameters.Add("DName", UniDbType.VarChar);
      parameter.Value = "DEPTNAME";
      cmd.Parameters.Add(parameter);
      parameter = cmd.Parameters.Add("Loc", UniDbType.VarChar);
      parameter.Value = "LOCATION";
      cmd.Parameters.Add(parameter);
      connection.Open();
      cmd.ExecuteNonQuery();
    }
    finally {
      connection.Close();
    }
    
    ...
    
    DataSet dataSet = new DataSet();
    UniDataAdapter da = new UniDataAdapter("SELECT * FROM dept",
      "Provider=Oracle;direct=true;data source=192.168.0.1;port=1521;sid=orcl;user=scott;password=tiger");
    da.Fill(dataSet, "Dept");
    
    
    Dim connection As Devart.Data.Universal.UniConnection = New _
      Devart.Data.Universal.UniConnection("Provider=Oracle;direct=true;data source=192.168.0.1;port=1521;sid=orcl;user=scott;password=tiger")
    Try
      Dim cmd As UniCommand = connection.CreateCommand()
      cmd.CommandText = "INSERT INTO dept (DeptNo, DName, Loc) VALUES (:DeptNo, :DName, :Loc)"
      Dim parameter As Devart.Data.Universal.UniParameter = cmd.Parameters.Add("DEPTNO", UniDbType.Int)
      parameter.Value = 150
      parameter = cmd.Parameters.Add("DName", UniDbType.VarChar)
      parameter.Value = "DEPTNAME"
      parameter = cmd.Parameters.Add("Loc", UniDbType.VarChar)
      parameter.Value = "LOCATION"
      connection.Open()
      cmd.ExecuteNonQuery()
    Finally
      connection.Close()
    End Try
    
    ...
    
    Dim dataSet As DataSet = New DataSet()
    Dim da As UniDataAdapter = New UniDataAdapter("Provider=Oracle;direct=true;data source=192.168.0.1;port=1521;sid=orcl;user=scott;password=tiger")
    da.Fill(dataSet, "Dept")
    
    

    Special Features

    dotConnect Universal supports handling Oracle BLOB, CLOB, and NCLOB field types. For detailed information on how to work with BLOB objects, refer to the Working with BLOB Data topic.

    dotConnect Universal supports the Oracle NUMBER type. Use the UniDecimal structure reference to find out how to manage big numbers on client side.

    dotConnect Universal supports Oracle cursos. For detailed information on how to handle cursors, refer to the Working with Cursors topic.

    It is also possible to take advantage of special network capabilities of dotConnect for Oracle by setting up the connection string parameters. This way you can enable:

    UniSQL Notes

    dotConnect for Oracle supports all features of UniSQL. Use Oracle predefined macro to build conditional UniSQL statements. For more information refer to the UniSQL topic.

    In some old versions of Oracle server SQL syntax for OUTER JOINs differs from common standard. UniSQL allows to do handle the difference easily with {oj ...} construct:
    {oj Outer_Join_Expression}

    UniDbType Map

    The following table shows how the UniDbType enumeration maps to the Oracle database type.

    UniDbType Oracle Type
    Array VARRAY
    BigInt NUMBER
    Binary RAW
    Bit NUMBER(p) [p<10]
    Blob LOB
    Boolean NUMBER
    Byte NUMBER(p) [p<10]
    Char CHAR
    Clob CLOB
    Currency NUMBER
    Cursor REF CURSOR
    Date DATE
    DateTime DATE
    Decimal NUMBER
    Double NUMBER(p,s)[p>=10 or S>0]
    Guid VARCHAR2
    Int NUMBER(p) [p<10]
    IntervalDS INTERVAL DAY TO SECOND
    IntervalYM INTERVAL YEAR TO MONTH
    NChar NCHAR
    NClob NCLOB
    NVarChar NVARCHAR
    Object One of the Oracle object types defined by the user
    Single An Oracle 10g BINARY_FLOAT
    SmallInt NUMBER(p) [p<10]
    TinyInt NUMBER(p) [p<10]
    Time DATE
    TimeStamp TIMESTAMP
    VarChar VARCHAR
    Xml XMLTYPE

    Additional Information

    For more information on dotConnect for Oracle Data Provider please visit the following locations:

    See Also

    Using dotConnect Universal with SQL Client  | Using dotConnect Universal with dotConnect for MySQL  | Using dotConnect Universal with dotConnect for PostgreSQL  | Using dotConnect Universal with dotConnect for SQLite  | Working with BLOB Data