且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ResultSet关闭后不允许操作(mysql,java)

更新时间:2023-11-09 20:19:04

Statement 对象只能有一个活动的 ResultSet ,所以当你执行 rs2时= stmt.executeQuery(sql),第一个ResultSet( rs )被关闭。

A Statement object can have only one active ResultSet, so when you execute rs2 = stmt.executeQuery(sql), the first ResultSet (rs) gets closed.

创建两个 Statement 对象,一个用于 rs ,另一个用于 rs2

Create two Statement objects, one for rs and another for rs2.

引用 Statement


默认情况下,每个 Statement 对象只能同时打开一个 ResultSet 对象。因此,如果读取一个 ResultSet 对象与另一个对象的读取交错,则每个必须由不同的 Statement 生成>对象。 Statement 接口中的所有执行方法都会隐式关闭一个语句的当前 ResultSet 对象(如果存在开放的对象)。

By default, only one ResultSet object per Statement object can be open at the same time. Therefore, if the reading of one ResultSet object is interleaved with the reading of another, each must have been generated by different Statement objects. All execution methods in the Statement interface implicitly close a statment's current ResultSet object if an open one exists.