Export (0) Print
Expand All

OracleConnectionStringBuilder Class

Note: This API is now obsolete.

Provides a simple way to create and manage the contents of connection strings used by the OracleConnection class.

System.Object
  System.Data.Common.DbConnectionStringBuilder
    System.Data.OracleClient.OracleConnectionStringBuilder

Namespace:  System.Data.OracleClient
Assembly:  System.Data.OracleClient (in System.Data.OracleClient.dll)

[ObsoleteAttribute("OracleConnectionStringBuilder has been deprecated. http://go.microsoft.com/fwlink/?LinkID=144260", 
	false)]
public sealed class OracleConnectionStringBuilder : DbConnectionStringBuilder

The OracleConnectionStringBuilder type exposes the following members.

  NameDescription
Public methodOracleConnectionStringBuilder()Initializes a new instance of the OracleConnectionStringBuilder class.
Public methodOracleConnectionStringBuilder(String)Initializes a new instance of the OracleConnectionStringBuilder class. The provided connection string provides the data for the instance's internal connection information.
Top

  NameDescription
Public propertyBrowsableConnectionStringGets or sets a value that indicates whether the ConnectionString property is visible in Visual Studio designers. (Inherited from DbConnectionStringBuilder.)
Public propertyConnectionStringGets or sets the connection string associated with the DbConnectionStringBuilder. (Inherited from DbConnectionStringBuilder.)
Public propertyCountGets the current number of keys that are contained within the ConnectionString property. (Inherited from DbConnectionStringBuilder.)
Public propertyDataSourceGets or sets the name of the Oracle data source to connect to.
Public propertyEnlistGets or sets a value that indicates whether the pooler automatically enlists the connection in the creation thread's current transaction context.
Public propertyIntegratedSecurityGets or sets a value that indicates whether "User ID" and "Password" are specified in the connection (when false) or whether the current Windows account credentials are used for authentication (when true).
Public propertyIsFixedSizeGets a value that indicates whether the OracleConnectionStringBuilder has a fixed size. (Overrides DbConnectionStringBuilder.IsFixedSize.)
Public propertyIsReadOnlyGets a value that indicates whether the DbConnectionStringBuilder is read-only. (Inherited from DbConnectionStringBuilder.)
Public propertyItemGets or sets the value associated with the specified key. In C#, this property is the indexer. (Overrides DbConnectionStringBuilder.Item[String].)
Public propertyKeysGets an ICollection that contains the keys in the OracleConnectionStringBuilder. (Overrides DbConnectionStringBuilder.Keys.)
Public propertyLoadBalanceTimeoutGets or sets the minimum time, in seconds, for the connection to live in the connection pool before it is removed.
Public propertyMaxPoolSizeGets or sets the maximum number of connections allowed in the connection pool for this specific connection string.
Public propertyMinPoolSizeGets or sets the minimum number of connections allowed in the connection pool for this specific connection string.
Public propertyOmitOracleConnectionNameGets or sets the flag that enables transaction rollbacks on earlier versions of Oracle (prior to 8.1.7.4.1).
Public propertyPasswordGets or sets the password for the Oracle account.
Public propertyPersistSecurityInfoGets or sets a Boolean value that indicates if security-sensitive information, such as the password, is not returned as part of the connection if the connection is open or has ever been in an open state.
Public propertyPoolingGets or sets a Boolean value that indicates whether the connection will be pooled, or whether each connection will be explicitly opened every time that the connection is requested.
Public propertyUnicodeGets or sets a Boolean value that indicates if the client supports the Unicode functionality available in later Oracle clients, or if it is non-Unicode aware.
Public propertyUserIDGets or sets the user ID to be used when connecting to Oracle.
Public propertyValuesGets an ICollection that contains the values in the OracleConnectionStringBuilder. (Overrides DbConnectionStringBuilder.Values.)
Top

  NameDescription
Public methodAddAdds an entry with the specified key and value into the DbConnectionStringBuilder. (Inherited from DbConnectionStringBuilder.)
Public methodClearClears the contents of the OracleConnectionStringBuilder instance. (Overrides DbConnectionStringBuilder.Clear().)
Protected methodClearPropertyDescriptorsClears the collection of PropertyDescriptor objects on the associated DbConnectionStringBuilder. (Inherited from DbConnectionStringBuilder.)
Public methodContainsKeyDetermines whether the OracleConnectionStringBuilder contains a specific key. (Overrides DbConnectionStringBuilder.ContainsKey(String).)
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Public methodEquivalentToCompares the connection information in this DbConnectionStringBuilder object with the connection information in the supplied object. (Inherited from DbConnectionStringBuilder.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Protected methodGetPropertiesFills a supplied Hashtable with information about all the properties of this DbConnectionStringBuilder. (Inherited from DbConnectionStringBuilder.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodRemoveRemoves the entry with the specified key from the OracleConnectionStringBuilder instance. (Overrides DbConnectionStringBuilder.Remove(String).)
Public methodShouldSerializeIndicates whether the specified key exists in this OracleConnectionStringBuilder instance. (Overrides DbConnectionStringBuilder.ShouldSerialize(String).)
Public methodToStringReturns the connection string associated with this DbConnectionStringBuilder. (Inherited from DbConnectionStringBuilder.)
Public methodTryGetValueRetrieves a value corresponding to the supplied key from this OracleConnectionStringBuilder. (Overrides DbConnectionStringBuilder.TryGetValue(String, Object).)
Top

  NameDescription
Explicit interface implemetationPrivate methodICollection.CopyToCopies the elements of the ICollection to an Array, starting at a particular Array index. (Inherited from DbConnectionStringBuilder.)
Explicit interface implemetationPrivate propertyICollection.IsSynchronizedGets a value indicating whether access to the ICollection is synchronized (thread safe). (Inherited from DbConnectionStringBuilder.)
Explicit interface implemetationPrivate propertyICollection.SyncRootGets an object that can be used to synchronize access to the ICollection. (Inherited from DbConnectionStringBuilder.)
Explicit interface implemetationPrivate methodICustomTypeDescriptor.GetAttributesReturns a collection of custom attributes for this instance of a component. (Inherited from DbConnectionStringBuilder.)
Explicit interface implemetationPrivate methodICustomTypeDescriptor.GetClassNameReturns the class name of this instance of a component. (Inherited from DbConnectionStringBuilder.)
Explicit interface implemetationPrivate methodICustomTypeDescriptor.GetComponentNameReturns the name of this instance of a component. (Inherited from DbConnectionStringBuilder.)
Explicit interface implemetationPrivate methodICustomTypeDescriptor.GetConverterReturns a type converter for this instance of a component. (Inherited from DbConnectionStringBuilder.)
Explicit interface implemetationPrivate methodICustomTypeDescriptor.GetDefaultEventReturns the default event for this instance of a component. (Inherited from DbConnectionStringBuilder.)
Explicit interface implemetationPrivate methodICustomTypeDescriptor.GetDefaultPropertyReturns the default property for this instance of a component. (Inherited from DbConnectionStringBuilder.)
Explicit interface implemetationPrivate methodICustomTypeDescriptor.GetEditorReturns an editor of the specified type for this instance of a component. (Inherited from DbConnectionStringBuilder.)
Explicit interface implemetationPrivate methodICustomTypeDescriptor.GetEvents()Returns the events for this instance of a component. (Inherited from DbConnectionStringBuilder.)
Explicit interface implemetationPrivate methodICustomTypeDescriptor.GetEvents(Attribute[])Returns the events for this instance of a component using the specified attribute array as a filter. (Inherited from DbConnectionStringBuilder.)
Explicit interface implemetationPrivate methodICustomTypeDescriptor.GetProperties()Returns the properties for this instance of a component. (Inherited from DbConnectionStringBuilder.)
Explicit interface implemetationPrivate methodICustomTypeDescriptor.GetProperties(Attribute[])Returns the properties for this instance of a component using the attribute array as a filter. (Inherited from DbConnectionStringBuilder.)
Explicit interface implemetationPrivate methodICustomTypeDescriptor.GetPropertyOwnerReturns an object that contains the property described by the specified property descriptor. (Inherited from DbConnectionStringBuilder.)
Explicit interface implemetationPrivate methodIDictionary.AddAdds an element with the provided key and value to the IDictionary object. (Inherited from DbConnectionStringBuilder.)
Explicit interface implemetationPrivate methodIDictionary.ContainsDetermines whether the IDictionary object contains an element with the specified key. (Inherited from DbConnectionStringBuilder.)
Explicit interface implemetationPrivate methodIDictionary.GetEnumeratorReturns an IDictionaryEnumerator object for the IDictionary object. (Inherited from DbConnectionStringBuilder.)
Explicit interface implemetationPrivate propertyIDictionary.ItemGets or sets the element with the specified key. (Inherited from DbConnectionStringBuilder.)
Explicit interface implemetationPrivate methodIDictionary.RemoveRemoves the element with the specified key from the IDictionary object. (Inherited from DbConnectionStringBuilder.)
Explicit interface implemetationPrivate methodIEnumerable.GetEnumeratorReturns an enumerator that iterates through a collection. (Inherited from DbConnectionStringBuilder.)
Top

This type is deprecated and will be removed in a future version of the .NET Framework. For more information, see Oracle and ADO.NET.

The connection string builders allow developers to programmatically create syntactically correct connection strings, and to parse and rebuild existing connection strings, using properties and methods of the class. The connection string builder provides strongly typed properties corresponding to the known key/value pairs allowed by Oracle. The OracleConnectionStringBuilder class implements the ICustomTypeDescriptor interface. This means that the class works with Visual Studio .NET designers at design time. When developers use the designer to build strongly typed DataSets and strongly typed connections within Visual Studio .NET, the strongly typed connection string builder class will display the properties associated with its type and will also have converters that can map common values for known keys.

Developers needing to create connection strings as part of applications can use the OracleConnectionStringBuilder class to build and modify connection strings. The OracleConnectionStringBuilder class also makes it easy to manage connection strings stored in an application configuration file.

The OracleConnectionStringBuilder performs checks for valid key/value pairs. Therefore, this class cannot be used to create invalid connection strings. Trying to add invalid pairs will throw an exception. The OracleConnectionStringBuilder class maintains a fixed collection of synonyms, and when required, can perform the required translation to convert from a synonym to the corresponding well-known key name. For example, when you use the Item property to retrieve a value, you can specify a string that contains any synonym for the key you need. See the Item property for a full list of acceptable synonyms.

The OracleConnectionStringBuilder handles attempts to insert malicious entries. For example, the following code, using the default Item property (the indexer, in C#) correctly escapes the nested key/value pair.

[Visual Basic]

Dim builder As New System.Data. _
    OracleClient.OracleConnectionStringBuilder
builder("Data Source") = "OracleDemo"
builder("Integrated Security") = True
builder("User ID") = "Mary;NewValue=Bad"
System.Diagnostics.Debug.WriteLine(builder.ConnectionString)

[C#]

System.Data.OracleClient.OracleConnectionStringBuilder builder =
   new System.Data.OracleClient.OracleConnectionStringBuilder();
builder["Data Source"] = "OracleDemo";
builder["integrated Security"] = true;
builder["User ID"] = "Mary;NewValue=Bad";
System.Diagnostics.Debug.WriteLine(builder.ConnectionString);

The result is the following connection string that handles the invalid value in a safe manner by enclosing the User ID value in quotes:

Data Source=OracleDemo;Integrated Security=True;User ID="Mary;NewValue=Bad"

The following console application builds connection strings for an Oracle database. The code uses an OracleConnectionStringBuilder class to create the connection string, and then passes the ConnectionString() property of the OracleConnectionStringBuilder instance to the constructor of the connection class. The example also parses an existing connection string, and demonstrates various ways of manipulating the connection string's contents.

NoteNote

This example includes a password to demonstrate how OracleConnectionStringBuilder works with connection strings. In your applications, we recommend that you use Windows Authentication. If you must use a password, do not include a hard-coded password in your application.


// You may need to set a reference to the System.Data.OracleClient
// assembly before you can run this sample.
using System.Data.OracleClient;

class Program
{
    static void Main()
    {
        // Create a new OracleConnectionStringBuilder and
        // initialize it with a few name/value pairs.
        OracleConnectionStringBuilder builder =
            new OracleConnectionStringBuilder(GetConnectionString());


        // Note that the input connection string used the 
        // Server key, but the new connection string uses
        // the well-known Data Source key instead.
        Console.WriteLine(builder.ConnectionString);

        // Pass the OracleConnectionStringBuilder an existing 
        // connection string, and you can retrieve and
        // modify any of the elements.
        builder.ConnectionString = "server=OracleDemo;user id=maryc;" +
            "password=pass@word1";

        // Now that the connection string has been parsed,
        // you can work with individual items.
        Console.WriteLine(builder.Password);
        builder.Password = "newPassword";
        builder.PersistSecurityInfo = true;

        // You can refer to connection keys using strings, 
        // as well. When you use this technique (the default
        // Item property in Visual Basic, or the indexer in C#),
        // you can specify any synonym for the connection string key
        // name.
        builder["Server"] = ".";
        builder["Load Balance Timeout"] = 1000;
        builder["Integrated Security"] = true;
        Console.WriteLine(builder.ConnectionString);

        Console.WriteLine("Press Enter to finish.");
        Console.ReadLine();
    }

    private static string GetConnectionString()
    {
        // To avoid storing the connection string in your code,
        // you can retrieve it from a configuration file. 
        return "Server=OracleDemo;Integrated Security=true";
    }
}


.NET Framework

Supported in: 3.5, 3.0, 2.0
Obsolete (compiler warning) in 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions

ADD
Show:
© 2014 Microsoft