您好,我有这样的查询:
PreparedStatement prep = conn.prepareStatement("update Products set amount=? where codebar=? and price=?;");
sqlite 有什么方法可以获取受影响的行数吗?我怎样才能得到它? 谢谢
最佳答案
试试这个 -
PreparedStatement prest = con.prepareStatement("update Products set amount=? where codebar=? and price=?");
prest.setDouble(1, 10.00);
prest.setInt(2, 1);
prest.setDouble(1, 50.00);
int rowCount = prest.executeUpdate();
executeUpdate()
的返回值是一个 int 值,指示更新了表的多少行。
查看以下链接以获取更多信息 -
http://docs.oracle.com/javase/tutorial/jdbc/basics/prepared.html
关于java - 如何获取sqlite中受影响的行数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14201986/