deleteRow的使用问题
import java.sql.*;
public class ProData {
public static void main(String args[]) {
Connection con;
PreparedStatement stmt;
ResultSet rs;
String sql = "select * from data order by id";
long id = 0;
//double data;
try {
System.out.println("OK");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:RTree");
stmt = con.prepareStatement(sql, ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
rs = stmt.executeQuery();
System.out.println(rs.getConcurrency());
while(rs.next())
{
id=rs.getLong("id");
if(id==3)
{
rs.deleteRow();
}
}
System.out.println("Finish!");
} catch (
SQLException e) {
System.out.println(e.getMessage());
System.out.println(e.getSQLState());
System.out.println(e.getErrorCode());
} catch (Exception e) {
}
}
}
如何将删除的结果更新到数据库中呢?文档里说deleteRow能够真正的将数据从数据库中删除,但是好像不行,那么如果使用该函数将数据真正从数据库中删除呢?
------解决方案--------------------你确定id是3?
SQLFeatureNotSupportedException异常也catch看看,
还有属性改为TYPE_SCROLL_SENSITIVE看看
------解决方案--------------------