OracleDataSourceEnumerator Class

An OracleDataSourceEnumerator object allows applications to generically obtain a collection of data sources to connect to.

Class Inheritance

System.Object

  System.DbDataSourceEnumerator

    Oracle.DataAccess.Client.OracleDataSourceEnumerator

Declaration

// C#
public sealed class OracleDataSourceEnumerator : DbDataSourceEnumerator

Requirements

Provider ODP.NET, Unmanaged Driver ODP.NET, Managed Driver
Assembly Oracle.DataAccess.dll Oracle.ManagedDataAccess.dll
Namespace Oracle.DataAccess.Client Oracle.ManagedDataAccess.Client
.NET Framework 3.5, 4.0, 4.5 4.0, 4.5

Thread Safety

All public static methods are thread-safe, although instance methods do not guarantee thread safety.

Example

// C#
 
using System;
using System.Data;
using System.Data.Common;
using Oracle.DataAccess.Client;
 
class DataSourceEnumSample
{
  static void Main()
  {
    string ProviderName = "Oracle.DataAccess.Client";
 
    DbProviderFactory factory = DbProviderFactories.GetFactory(ProviderName);
 
    if (factory.CanCreateDataSourceEnumerator)
    {
      DbDataSourceEnumerator dsenum = factory.CreateDataSourceEnumerator();
      DataTable dt = dsenum.GetDataSources();
 
      // Print the first column/row entry in the DataTable
      Console.WriteLine(dt.Columns[0] + " : " + dt.Rows[0][0]);
      Console.WriteLine(dt.Columns[1] + " : " + dt.Rows[0][1]);
      Console.WriteLine(dt.Columns[2] + " : " + dt.Rows[0][2]);
      Console.WriteLine(dt.Columns[3] + " : " + dt.Rows[0][3]);
      Console.WriteLine(dt.Columns[4] + " : " + dt.Rows[0][4]);
    }
    else
      Console.Write("Data source enumeration is not supported by provider");
  }
}

OracleDataSourceEnumerator Members

OracleDataSourceEnumerator members are listed in the following tables.

OracleDataSourceEnumerator Constructor

OracleDataSourceEnumerator Public Methods are listed in Table 6-60.

Table 6-60 OracleDataSourceEnumerator Method

Method Description

OracleDataSourceEnumerator Constructor

Instantiates a new instance of the OracleDataSourceEnumerator class


OracleDataSourceEnumerator Public Methods

OracleDataSourceEnumerator Public Methods are listed in Table 6-61.

Table 6-61 OracleDataSourceEnumerator Method

Method Description

GetDataSources

Returns a DataTable object with information on all the TNS alias entries in the tnsnames.ora file and entries retrieved from the LDAP servers configured in ldap.ora if LDAP Naming is enabled


OracleDataSourceEnumerator Constructor

OracleDataSourceEnumerator constructor creates new instances of an OracleDataSourceEnumerator class.

Declaration

// C#
public OracleDataSourceEnumerator();

OracleDataSourceEnumerator Public Methods

The OracleDataSourceEnumerator static method is listed in Table 6-62.

Table 6-62 OracleDataSourceEnumerator Method

Method Description

GetDataSources

Returns a DataTable object with information on all the TNS alias entries in the tnsnames.ora file


GetDataSources

This method returns a DataTable object with information on all the TNS alias entries in the tnsnames.ora file and entries retrieved from the LDAP servers configured in ldap.ora if LDAP naming is enabled.

Declaration

// C#
public override DataTable GetDataSources();
 

Return Value

A DataTable object.

Remarks

This method returns a DataTable object for each TNS alias entry that exists in the tnsnames.ora file and each entry retrieved from the LDAP servers. If a tnsnames.ora file is not found and LDAP Naming is not configured, then the returned DataTable object will be empty.

When Oracle Internet Directory (OID) is used for the TNS naming repository, there is a limit of 1000 TNS entries retrieved.

The following columns are returned for each row, but only the InstanceName column is populated.

  • InstanceName (type: System.String)

  • ServerName (type: System.String)

  • ServiceName (type: System.String)

  • Protocol (type: System.String)

  • Port (type: System.String)

If the TNS and/or LDAP information changes for existing pooled connections, then calling GetDataSources will not return these changes unless the pools have been cleared.