快速业务通道

購噐weblogic嶄聞喘prepared statement cache朔荷恬DDL議諒籾 - 園殻秘壇利

作者 佚名技术 来源 NET编程 浏览 发布时间 2012-06-21
on)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.

This parameter is applicable only if the application gets a connection from the connection pool and then calls the getVendorConnection() method on that object. The getVendorConnection() method returns a vendor specific connection to the caller of the method which might leave the connection pool in an inconsistent state. As a result, WebLogic Server might remove it from the pool assuming it is an infected connection.

Enabling this attribute will have an impact on performance as it will essentially disable the pooling of connections. This is because connections will be removed from the pool and replaced with new connections.

因为我们这个问题必须关闭physical connection, 所以采用默认配置就可以了。你也许还会有疑问,physical connection被关闭了,如果我反复搞这么几次,connection不就被关完了?其他应用怎么办?不用担心,有connection pool呢,在getVendorConnection()被调用的时候, connection会检查Remove Infected Connections Enabled,如果为true,即这个logical connection对应的physical connection不会被重用,它会schedule一个创建physical connection的动作,以补充那个抛弃我们的phisical connection。最后关闭连接的时候,logical connection会被废弃,physical connection被关闭。

而我在测试中,尝试自己去关闭vendor connection,如下:

1     private void initializeConnection() throws SQLException 2     { 3         //this test should be run in local jvm, as oracle.jdbc.driver.T4CConnection 4         //is not a serializable object. 5         //java.io.NotSerializableException: oracle.jdbc.driver.T4CConnection 6         this.conn = this.retriver.getJBDCConnection(dsName); 7         this.wlConn = (WLConnection)this.conn; 8         this.oraConn = (OracleConnection)this.wlConn.getVendorConnection(); 9         System.out.println(this.conn.toString()); 10         System.out.println(this.oraConn.toString()); 11     } 12      13     private void pstmtTest() 14     { 15         try 16   

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号