我需要关闭"PreparedStatement"吗? [英] Do I need to close 'PreparedStatement'?

查看:143
本文介绍了我需要关闭"PreparedStatement"吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站,它的点击量很高.我遇到了很多问题,包括JDBC连接错误.

I have a website which is getting a massive number of hits. I'm experienced problems, including JDBC connection errors.

我对关闭 PreparedStatement 有点困惑.我是否需要关闭 PreparedStatement 还是仅关闭 Statement 足够了吗?

I'm a bit confused about closing PreparedStatement. Do I need to close PreparedStatement or is it just enough to only close Statement?

另外, ResultSet 又如何呢?我也需要关闭它吗?

Also, what about ResultSet? Do I need to close it too?

推荐答案

是的,您必须关闭准备好的语句( PreparedStatement 对象)和结果集,因为它们可能会导致内存泄漏.

Yes, you have to close the prepared statements (PreparedStatement Object) and result sets as they may cause memory leakage.

有关更多信息,请参见 使用预备语句 .

For more information, see Using Prepared Statements.

这篇关于我需要关闭"PreparedStatement"吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆