ODP.NET connection pooling: How to tell if a connection has been used

后端 未结 3 1415
礼貌的吻别
礼貌的吻别 2020-12-20 00:17

I\'m modifying a Winforms app to use connection pooling so data access can occur in background threads. The business logic is implemented in PL/SQL and there are a couple of

3条回答
  •  太阳男子
    2020-12-20 00:59

    The connection pooling provided by ODP.NET is completely opaque. That is, it isn't leaky in the way I'd like it to be - there is no way of knowing if a connection has been used before or is brand new. However it is a leaky abstraction in another way: Any session state (e.g. package scoped variables, which are session scoped) is preserved between usages of the connection. Since this is a question about determining the used vs. new state of a connection without going to the database, the answer is that it simply cannot be done using ODP.NET's built-in connection pool.

    That leaves two options:

    1. Create a connection pool implementation that either provides that information or performs user-defined initialisation upon creation of each new connection; or
    2. Perform a round-trip to the database to determine the used vs. new state of the connection.

提交回复
热议问题