]> WPIA git - gigi.git/commitdiff
fix: transactions this way are buggy, we need a better way... will come.
authorFelix Dörre <felix@dogcraft.de>
Wed, 8 Jun 2016 15:23:01 +0000 (17:23 +0200)
committerFelix Dörre <felix@dogcraft.de>
Wed, 8 Jun 2016 15:37:17 +0000 (17:37 +0200)
Change-Id: I22205bff3d5aae783096b50bc89fb9810c279f26

src/org/cacert/gigi/database/DatabaseConnection.java
src/org/cacert/gigi/pages/main/Signup.java

index bf7cd3be38bea730e76b90cf1e5accf1c577929b..c85b5348d6e253c2dd96d1219723b9913751db23 100644 (file)
@@ -217,10 +217,6 @@ public class DatabaseConnection {
         upgrade(version);
     }
 
-    public void beginTransaction() throws SQLException {
-        c.setAutoCommit(false);
-    }
-
     private static void upgrade(int version) {
         try {
             Statement s = getInstance().c.createStatement();
@@ -248,22 +244,6 @@ public class DatabaseConnection {
         }
     }
 
-    public void commitTransaction() throws SQLException {
-        c.commit();
-        c.setAutoCommit(true);
-    }
-
-    public void quitTransaction() {
-        try {
-            if ( !c.getAutoCommit()) {
-                c.rollback();
-                c.setAutoCommit(true);
-            }
-        } catch (SQLException e) {
-            e.printStackTrace();
-        }
-    }
-
     public static final String preprocessQuery(String originalQuery) {
         originalQuery = originalQuery.replace('`', '"');
         if (originalQuery.matches("^INSERT INTO [^ ]+ SET .*")) {
index 0cadcf64a8c4575b9d94831c59c0b95c43e5e69d..f55c2fdc56e25d5deb1f1f07afe36ab308d1ba06 100644 (file)
@@ -9,7 +9,6 @@ import java.util.Map;
 import javax.servlet.http.HttpServletRequest;
 
 import org.cacert.gigi.GigiApiException;
-import org.cacert.gigi.database.DatabaseConnection;
 import org.cacert.gigi.database.GigiPreparedStatement;
 import org.cacert.gigi.database.GigiResultSet;
 import org.cacert.gigi.dbObjects.Name;
@@ -174,24 +173,16 @@ public class Signup extends Form {
     }
 
     private void run(HttpServletRequest req, String password) throws SQLException, GigiApiException {
-        try {
-            DatabaseConnection.getInstance().beginTransaction();
-            User u = new User(email, password, buildupName, myDoB.getDate(), Page.getLanguage(req).getLocale());
-
-            try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `alerts` SET `memid`=?," + " `general`=?, `country`=?, `regional`=?, `radius`=?")) {
-                ps.setInt(1, u.getId());
-                ps.setBoolean(2, general);
-                ps.setBoolean(3, country);
-                ps.setBoolean(4, regional);
-                ps.setBoolean(5, radius);
-                ps.execute();
-            }
-            Notary.writeUserAgreement(u, "CCA", "account creation", "", true, 0);
+        User u = new User(email, password, buildupName, myDoB.getDate(), Page.getLanguage(req).getLocale());
 
-            DatabaseConnection.getInstance().commitTransaction();
-        } finally {
-            DatabaseConnection.getInstance().quitTransaction();
+        try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `alerts` SET `memid`=?," + " `general`=?, `country`=?, `regional`=?, `radius`=?")) {
+            ps.setInt(1, u.getId());
+            ps.setBoolean(2, general);
+            ps.setBoolean(3, country);
+            ps.setBoolean(4, regional);
+            ps.setBoolean(5, radius);
+            ps.execute();
         }
-
+        Notary.writeUserAgreement(u, "CCA", "account creation", "", true, 0);
     }
 }