DB2 10.5 for Linux, UNIX, and Windows

DB2Connection.ReleaseObjectPool Method

Indicates that the resources of the connection pool can be released when the last underlying connection is released.

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

Syntax

[Visual Basic]
Public Shared Sub ReleaseObjectPool()
[C#]
public static void ReleaseObjectPool();
[C++]
public: static void ReleaseObjectPool();
[JScript]
public static function ReleaseObjectPool();

Remarks

ReleaseObjectPool can be called to release the resources of the connection pool. You can call this method if, for example, the connection object will not be used again. When all connections in the pool are closed, the pool can be disposed of. Note that calling the method alone does not actually release the active connections that exist in the pool.

The following steps must occur before the pool is finally disposed:
  1. Call Close to release the DB2®Connection object from the environment.
  2. Allow each connection object to time out.
  3. Call ReleaseObjectPool.
  4. Invoke garbage collection.

Conversely, if you call Close on all active connections, and invoke garbage collection, but do not call ReleaseObjectPool, the resources reserved for the pool will remain available.

After a pool is released, a request for a new DB2Connection creates a new pool.

Example

[Visual Basic, C#] The following example creates a DB2Connection , opens it, displays some of its properties, closes the connection and releases the object pool to conserve resources.

[Visual Basic]
Public Sub CreateDB2Connection(myConnString As String)
     Dim myConnection As New DB2Connection(myConnString)
     myConnection.Open()
     MessageBox.Show("State: " + myConnection.State.ToString())
     myConnection.Close()
     DB2Connection.ReleaseObjectPool()
 End Sub

[C#]
public void CreateDB2Connection(string myConnString)
 {
    DB2Connection myConnection = new DB2Connection(myConnString);
    myConnection.Open();
    MessageBox.Show("State: " + myConnection.State.ToString());
    myConnection.Close();
    DB2Connection.ReleaseObjectPool();
 }