We have a client/server application that consists of multiple EXEs. The data access layer is on the same physical tier as the client in a library shared by our EXE modules. ODBC and OleDB connection pools are managed per-process; are there techniques for sharing DB connections across processes (other than moving the data access layer to a middle tier)?
Database connections in OLEDB and ODBC are intrinsically process bound. At the lowest levels, a sql server database connection is using an IPC mechanism like named pipes, shared memory, or tcp sockets. Other databases probably use network connections exclusively. If you think about it, to share a connection pool and hence connections you would need to copy these low level objects (sockets, named pipe, shared memory section) to another process and then allow them to manage them. Even if you could hand them off you wouldn't be able to use them concurrently.
To do what you want to do you really have to move the data access layer into a shared space that all of your multiple exes want to use. This is usually a middle tier and each exe would then communicate with that via some IPC mechanism (.net remoting, com server, RPC, networking, etc).
来源:https://stackoverflow.com/questions/365984/db-connection-pool-across-processes