こんにちは私はこのようなクエリがあります:
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 documentationによると、メソッドを使用executeUpdate()
して更新された行の数を取得できます。
基準に一致する行数をカウントするために、更新の前に select ステートメントを実行することはできませんか?