Databases Reference
In-Depth Information
Creating a New Connection One at a Time as Needed
When you create a new connection one at a time as needed, you can design your
application to create either of the following:
One connection for each statement to be executed
One connection for multiple statements, which is often referred to as using
multiple threads
Figure 2-2 compares these two connection models.
One Connection for Multiple Statements
One Connection for Each Statement
S 1
S 1
C 1
S 2
S 2
C 2
C 1
S 3
S 3
C 3
S 4
S 4
C 4
S 5
S 5
C 5
Connection C 1
Statements S 1 , S 2 , S 3 , S 4 , S 5
all share connection C 1 .
Connections C 1 , C 2 , C 3 , C 4 , C 5
Statements S 1 , S 2 , S 3 , S 4 , S 5
all have their own connection.
Figure 2-2
Comparing two connection models
The advantage of using one connection for each statement is that each state-
ment can access the database at the same time. The disadvantage is the overhead
of establishing multiple connections.
The advantages and disadvantages of using one connection for multiple
statements are explained later in this section.
One Connection for Multiple Statements
Before we can explain the details of one connection for multiple statements, we
need to define statement . Some people equate “statement” to “SQL statement.”
We like the definition of “statement” that is found in the Microsoft ODBC 3.0
Programmer's Reference :
Search WWH ::




Custom Search