我在一个循环中使用PreparedStatement :
|
请问,我这样用PreparedStatement对吗????
PreparedStatement 是应该写在循环体里面,还是应该放到循环体外面呢???
我在一个循环中使用PreparedStatement :
|
外面
写里面可能也没问题,因为SQL脚本的缓存最终还是由数据库实现的。
我也不太确定。
看你的需求了,里面外面都可以吧,藕以为。。。
那写在外面是不是会快点
在里面有时会出问题!
你的循环太大了,一个conn可以创建的Statement对象是有限的。
How come put the PreparedState in the loop?
The following codes looks better.
|
我试了一下,oracle可以打开300个。db2不限(不过这并不代表能顺利完成所有操作)。