]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/database/DatabaseConnection.java
Removed Data table. this idea was crap
[gigi.git] / src / org / cacert / gigi / database / DatabaseConnection.java
index 9f9193a7ad0f2fedafaa45fccb415fd22e33b8d2..6bed8bd979c2f62aec1b7922779bed3048716063 100644 (file)
@@ -44,7 +44,8 @@ public class DatabaseConnection {
                ensureOpen();
                PreparedStatement statement = statements.get(query);
                if (statement == null) {
-                       statement = c.prepareStatement(query);
+                       statement = c.prepareStatement(query,
+                                       Statement.RETURN_GENERATED_KEYS);
                        statements.put(query, statement);
                }
                return statement;
@@ -80,10 +81,30 @@ public class DatabaseConnection {
        public static DatabaseConnection getInstance() {
                return instances.get();
        }
+       public static boolean isInited() {
+               return credentials != null;
+       }
        public static void init(Properties conf) {
                if (credentials != null) {
                        throw new Error("Re-initiaizing is forbidden.");
                }
                credentials = conf;
        }
+       public void beginTransaction() throws SQLException {
+               c.setAutoCommit(false);
+       }
+       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();
+               }
+       }
 }