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

查看:27
本文介绍了我需要关闭“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天全站免登陆