0

こんにちは私はこのようなクエリがあります:

PreparedStatement prep = conn.prepareStatement("update Products set amount=? where codebar=? and price=?;");

影響を受ける行の数を取得するためのsqliteの方法はありますか?そして、どうすればそれを入手できますか?どうも

4

3 に答える 3

3

これを試して -

  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

于 2013-01-07T19:08:49.627 に答える
2

Java documentationによると、メソッドを使用executeUpdate()して更新された行の数を取得できます。

于 2013-01-07T18:44:25.527 に答える
0

基準に一致する行数をカウントするために、更新の前に select ステートメントを実行することはできませんか?

于 2013-01-07T18:42:37.730 に答える