ODP.NET默认使用连接池.通常没有问题,但是当用户在连接错误后重试操作时,NHibernate从ODP.NET获取无效(池化)连接.用户必须重试多次(直到池为空)才能再次工作.@H_404_2@
当然我可以禁用ODP.NET中的连接池,但是我想避免这种情况.我还读了一个设置,检查从池中每个返回的连接到DB的连接,但这又增加了我想避免的每个连接的一次往返.@H_404_2@
The Validate Connection attribute validates connections coming out of the pool. This attribute should be used only when absolutely necessary,because it causes a round-trip to the database to validate each connection immediately before it is provided to the application. If invalid connections are uncommon,developers can create their own event handler to retrieve and validate a new connection,rather than using the Validate Connection attribute. This generally provides better performance.@H_404_2@
如果它不够好 – 你可以尝试从oracle的this文档.@H_404_2@
Connection Pool Management@H_404_2@
ODP.NET connection pool management provides explicit connection pool
control to ODP.NET applications. Applications can explicitly clear
connections in a connection pool.@H_404_2@Using connection pool management,applications can do the following:@H_404_2@
Note: These APIs are not supported in a .NET stored procedure. Clear
connections from connection pools using the ClearPool method.@H_404_2@Clear connections in all the connection pools in an application
domain,using the ClearAllPools method.@H_404_2@When connections are cleared from a pool,ODP.NET repopulates the pool
with new connections that have at least the number of connections set
by Min Pool Size in the connection string. New connections do not
necessarily mean the pool will have valid connections. For example,if
the database server is down when ClearPool or ClearAllPools is called,
ODP.NET creates new connections,but these connections are still
invalid because they cannot connect to the database,even if the
database comes up a later time.@H_404_2@It is recommended that ClearPool and ClearAllPools not be called until
the application can create valid connections back to the database.
.NET developers can develop code that continuously checks whether or
not a valid database connection can be created and calls ClearPool or
ClearAllPools once this is true.@H_404_2@
更新:
正如@MPelletier所指出的那样,对于oracle 12 the link is different.@H_404_2@