DB2 Version 10.1 for Linux, UNIX, and Windows

DB2Factory Class

Represents a set of methods for creating instances of the System.Data.Common data source classes for the IBM® Data Server Provider for .NET.

Namespace:
IBM.Data.DB2®
Assembly:
IBM.Data.DB2 (in IBM.Data.DB2.dll)

Inheritance hierarchy

System.Object
   System.Data.Common.DbProviderFactory
      IBM.Data.DB2.DB2Factory

Syntax

[Visual Basic]
Public NotInheritable Class DB2Factory
	Inherits DbProviderFactory
[C#]
public sealed class DB2Factory : DbProviderFactory
[C++]
public ref class DB2Factory sealed : public DbProviderFactory
[JScript]
public final class DB2Factory extends DbProviderFactory

Example

[C#] The following example demonstrates the creation of a DbConnection instance, using the DB2Factory.CreateConnection method.

[C#]
DB2Factory myFactory = DB2Factory.Instance;
DbConnection conn = myFactory.CreateConnection();

[C#] You can also get a database factory instance by using the generic DbProviderFactories class. In the following example, which accomplishes the same task as the previous example, note the "IBM.Data.DB2" string passed to the GetFactory method. This string uniquely identifies the IBM Data Server Provider for .NET from all other .NET data providers.

[C#]
DbProviderFactory myFactory = DbProviderFactories.GetFactory("IBM.Data.DB2");
DbConnection conn = myFactory.CreateConnection();

Thread safety

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

Version information

Last update
This topic was last updated for: IBM DB2 Version 9.5
.NET Framework version
Supported in: 2.0 and 3.0
IBM Data Server Client
Supported in: IBM DB2 Version 9