the Statement
API says:
By default, only one
ResultSet
object perStatement
object can be open at the same time. Therefore, if the reading of oneResultSet
object is interleaved with the reading of another, each must have been generated by differentStatement
objects. All execution methods in theStatement
interface implicitly close a statment's currentResultSet
object if an open one exists.
resultset 代码复用:
prmstatmenttimestamp.setInt(1, mod_t);
rstimestamp=prmstatmenttimestamp.executeQuery();
rstimestamp.next();
String mod_tsting=rstimestamp.getString(1);
prmstatmenttimestamp.setInt(1, xvcmodt);
rstimestamp=prmstatmenttimestamp.executeQuery();
rstimestamp.next();
代码会提示:Resource leak: 'rstimestamp' is not closed at this location
其实参考上面的 说明可知,only one ResultSet
object per Statement
object。所以对于如果想复用statement 可以考虑: