]> WPIA git - gigi.git/commitdiff
UPD: Forcing Update to be single-update or fail otherwise.
authorFelix Dörre <felix@dogcraft.de>
Sun, 1 Feb 2015 00:23:45 +0000 (01:23 +0100)
committerFelix Dörre <felix@dogcraft.de>
Sun, 1 Feb 2015 01:31:10 +0000 (02:31 +0100)
src/org/cacert/gigi/database/GigiPreparedStatement.java
src/org/cacert/gigi/dbObjects/User.java

index 81e5f4e31aa27004efb9df0468b1a2b31784b516..55ed6ad3d53d003ae6639c575dc19147a36cdfd0 100644 (file)
@@ -23,9 +23,12 @@ public class GigiPreparedStatement {
         }
     }
 
-    public int executeUpdate() {
+    public void executeUpdate() {
         try {
-            return target.executeUpdate();
+            int updated = target.executeUpdate();
+            if (updated != 1) {
+                throw new Error("FATAL: multiple or no data updated: " + updated);
+            }
         } catch (SQLException e) {
             handleSQL(e);
             throw new Error(e);
index 23636a919382af0a64136587e6f239c30fc80077..b42b6d51f6874f1314511ee2367e9b0467b298d1 100644 (file)
@@ -141,9 +141,7 @@ public class User extends CertificateOwner {
         ps = DatabaseConnection.getInstance().prepare("UPDATE users SET `password`=? WHERE id=?");
         ps.setString(1, PasswordHash.hash(newPass));
         ps.setInt(2, getId());
-        if (ps.executeUpdate() != 1) {
-            throw new GigiApiException("Password update failed.");
-        }
+        ps.executeUpdate();
     }
 
     public void setName(Name name) {