Home | Previous Page | Next Page   Database Access > Handling Connections >

Closing a Connection

To close a connection, free the associated connection descriptor. When the connection descriptor is freed, the DataBlade API also frees the session-context resources, including the following:

To conserve resources, use mi_close( ) to deallocate the connection descriptor explicitly once your DataBlade API module no longer needs it. The mi_close( ) function is the destructor function for a connection descriptor. It frees the connection descriptor and any resources that are associated with it.

Server Only

In a C UDR, a public connection descriptor has a memory duration of PER_STMT_EXEC. Therefore, a connection descriptor remains active until one of the following events occurs:

When a UDR connection is closed, the UDR can no longer access the associated connection information (see Table 44). However, the session remains open until the client application ends it. Therefore, a UDR can obtain a new UDR connection with another call to mi_open( ).

Tip:
After a C UDR closes a connection, the UDR can no longer access the connection resources in Table 44. Any open smart large objects and operating-system files, however, remain valid for the duration of the session. You can explicitly close these descriptors with the mi_lo_close( ) and mi_file_close( ) functions, respectively.

A session-duration connection descriptor has a memory duration of PER_SESSION. Therefore, it and its associated connection information remain valid until the end of the session. However, a session-duration connection is a restricted feature of the DataBlade API. Use it only when a public connection descriptor will not perform the task you need. For more information, see Obtaining a Session-Duration Connection Descriptor.

End of Server Only
Client Only

In a client LIBMI application, a connection descriptor has a scope of the session. When the client connection closes, the session ends. Therefore, a connection descriptor remains active until one of the following events occurs:

Tip:
Once a client LIBMI application closes a connection, it can no longer access the connection information. In addition, any open smart large objects and files are closed.
End of Client Only
Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]