关于weblogic中使用prepared statement cache后操作DDL的问题
2009-09-22 00:00:00 来源:WEB开发网如代码中的注释说的一样,单纯的重建prepared statement是没用的,需要重建physical connection. 这个代码中connection没有通过weblogic, 直接从driver manager拿connection, 问题一样能够复现,跟weblogic没关系了吧。
好了,知道为什么了,但怎么办呢? physical connection是weblogic在connection pool中维护的,我们怎么去控制它们啊?看文档, weblogic的jdbc programming提到了具体的操作方法,链接如下:
http://e-docs.bea.com/wls/docs81/jdbc/thirdparty.html#1108224
1 java.sql.Connection vendorConn = ((WLConnection)conn).getVendorConnection();
2 // do not close vendorConn
3 // You could also cast the vendorConn object //to a vendor interface, such as:
4 // oracle.jdbc.OracleConnection vendorConn = (OracleConnection)
文档中不建议我们自己去关闭vendor connection,而是由connection pool自己去管理,connection pool通过Remove Infected Connections Enabled来控制physical connection如何还池,
Applies only to physical database connections.
When set to true, the physical connection is not returned to the connection pool after the application closes the logical connection. Instead, the physical connection is closed and recreated.
Note: It is recommended that you set this flag to true as such connections are not managed by WebLogic Server.
When set to false, if you close the logical connection, the physical connection is returned to the connection pool. If you use this setting, ensure that the database connection is suitable for reuse by other applications.
更多精彩
赞助商链接