简体   繁体   English

是否需要对java.sql.Array / Blob / Clob类型进行“ free()”处理?

[英]Do java.sql.Array/Blob/Clob types need to be “free()”ed?

Do I need an explicit to call free() on Arrays, clobs etc... or will closing the ResultSet and/or Statement automatically take care of this? 我是否需要显式调用Array,clobs等上的free() ,或者关闭ResultSet和/或Statement会自动解决此问题? The javadoc doesn't say anything, so I assume that it's not necessary, but I would hate to make an incorrect assumption. Javadoc没有说什么,所以我认为这是没有必要的,但是我讨厌做出错误的假设。

Also, if its not necessary, is it a good idea if you're going to close the result set right away? 另外,如果不需要,是否立即关闭结果集是个好主意吗? I could see how it might help if you're not going to do so. 如果您不这样做,我可以看到有什么帮助。

It depends on the Vendor and JDBC version you are using. 这取决于您使用的供应商和JDBC版本。 As all databse vendors do not support Array(eg MySQL) 由于所有数据库供应商均不支持Array(例如MySQL)

And this could be the reason Why the javadoc doesn't say anything. 这可能就是javadoc什么都没说的原因。

I have found this tutorial Using Array Object on oracle site's JavaSE tutorials which says to release resources explicitly. 我已经在Oracle网站的JavaSE教程中找到了本教程“ 使用数组对象” ,该教程说要显式释放资源。

Here is another link which illustrates scenario of on free() . 这是另一个说明on free()场景的链接。 JDBC 4's java.sql.Clob.free() method and backwards compatibility JDBC 4的java.sql.Clob.free()方法和向后兼容

if its not necessary, is it a good idea if you're going to close the result set right away? 如果不需要,是否立即关闭结果集是个好主意吗?

I think then there should not be required to free(),but again if its a long running transcation,then its good to call free(). 我认为然后就不需要free()了,但是如果它长时间运行,那么再次调用free()很好。

Quoting from the tutorial : 引用本教程

Array objects remain valid for at least the duration of the transaction in which they are created. 数组对象至少在创建它们的事务期间保持有效。 This could potentially result in an application running out of resources during a long running transaction. 在长时间运行的事务中,这可能导致应用程序资源不足。 Applications may release Array resources by invoking their free method. 应用程序可以通过调用其free方法来释放Array资源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM