Begin detailed description.
This figure depicts the relationship between the parent thread, the connection pool, and child threads in a multithreading application. The steps that the parent thread performs and the steps that the child thread performs are presented separately in this description.
The following table outlines the steps that
the parent thread takes to establish and manage connection pooling
and describes each step.
| Step in the parent thread | Description |
|---|---|
| SQLAllocHandle() | Allocates the environment handle. |
| pthread_create 1
pthread_create 2 . . . pthread_create m |
Creates child threads 1 through n. |
SQLAllocHandle() 1SQLAllocHandle() 2. . . SQLAllocHandle() n |
Allocates the connection handles 1 through m. These handles make up the connection pool. |
| Mark connection handle as in use
Pass connection handle to child threads |
Marks a connection handle as in use when a child thread requests a connection. This action removes the handle from the connection pool. The parent thread then passes this connection handle to the child thread. |
| Mark connection handle free | Marks the connection handle as free, when a child thread signals it is finished using that handle. This action returns the connection handle to the connection pool. |
SQLFreeHandle() 1 - n |
Frees connection pool for shutdown. |
| pthread_join() 1 - m | Signals child threads to end for shutdown. |
The following table outlines the steps that
each child thread performs to establish a connection in a connection
pooling environment.
| Step in the child thread | Description |
|---|---|
| Request a connection handle
SQLConnect() |
Requests a connection handle from the parent thread. After this connection handle is received, the child thread can connect to a database. |
SQLAllocHandle() SQLExecDirect()SQLEndTran()SQLDisconnect() |
Allocates a statement handle and performs processing. |
| Signal to the parent that the connection handle is now available | Instructs the parent thread to mark the connection handle as free and to return that handle to the connection pool. |
| Wait for more work | Waits for more work and another connection handle from the parent thread. |
End detailed description.