deleterow()的问题.

quinton 2004-10-26 03:29:00
Statement stmt = conn.createStatement(
ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
到rs.deleteRow()就是说我对只读结果集没法删除.

在线等谢.
...全文
120 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
youthy_yy 2004-10-26
  • 打赏
  • 举报
回复
eg.

public void deleteRow() throws SQLException {
System.out.println("Start deleteRow");
Statement statement = null;
ResultSet resultSet = null;
int i = 1;
statement =
connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql = "select oid, * from perf_data where
username='abc'"; //This can be any select statement
//statement.setFetchSize(1000);

resultSet = statement.executeQuery( sql );
resultSet.last();
System.out.println("row count: " + resultSet.getRow());
resultSet.beforeFirst();
while ( resultSet.next()) {

System.out.println( "row #: " + resultSet.getRow());
System.out.println("Deleting Row:" + i);
resultSet.deleteRow();
System.out.println("Done Deleting Row:" + i);
System.out.println( "row #: " + resultSet.getRow());
i++;
}
resultSet.close();
statement.close();
System.out.println("End deleteRow");
}

quinton 2004-10-26
  • 打赏
  • 举报
回复
没明白.我没有对这个表进行INSERT操作呀.
youthy_yy 2004-10-26
  • 打赏
  • 举报
回复
/**
* Deletes the current row from this <code>ResultSet</code> object
* and from the underlying database. This method cannot be called when
* the cursor is on the insert row.
*
* @exception SQLException if a database access error occurs
* or if this method is called when the cursor is on the insert row
* @since 1.2
*/
void deleteRow() throws SQLException;


This method cannot be called when the cursor is on the insert row.

quinton 2004-10-26
  • 打赏
  • 举报
回复
有人回吗谢谢.

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧