ODBC - multiple connections from one app to the same data source
I vaguely remember reading somewhere (in MSDN ODBC documentation?) that one application cannot make more than one connection to a single data source. It seemed to me that I need one connection that all the threads of the application will have to share. I was trying to look this information up, but I can'开发者_Python百科t seem to find it anymore. Does anyone know/remember how this works?
It all might become a problem in our app, since some of its threads will dynamically connect to data sources of their choice. I don't want to see random connection errors if two of them will connect at the same time to one source, so I wanted to double check this info.Maybe the statement you are referring to in the MSDN documentation, is the one that says only one statement can be active on a single connection. It says:
Multiple Active Statements per Connection
After SQL Server has received a statement, the SQL Server TDS protocol does not allow acceptance of any other statements from that connection until one of the following occurs:
- The client application processes the entire result set.
- The client sends a statement telling the server it can close the remainder of the result set.
This means that when an ODBC application is using a default result set, SQL Server does not support multiple active statement handles on a connection handle and only one statement can be actively processed at any point in time.
When an ODBC application is using API server cursors, however, the driver can support multiple active statements on a connection. When the rowset for each cursor command has been received back at the client, SQL Server considers the statement to have completed, and it accepts another statement from another statement handle over that connection handle.
Multiple connections are fine. Multiple statements per connection, not so fine.
No, there is no restriction like that in ODBC itself. It is possible that a specific driver might for some reason limit the connections, but I am not aware of any limitations according to the specification.
精彩评论