From: Christian Grothoff Date: Wed, 27 Oct 2010 14:41:20 +0000 (+0000) Subject: proper transactions X-Git-Tag: initial-import-from-subversion-38251~19917 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=39d3a23b251dbfda4652c75699fc3d434a7df52f;p=oweals%2Fgnunet.git proper transactions --- diff --git a/src/monkey/seaspider/org/gnunet/seaspider/ExpressionDatabaseHandler.java b/src/monkey/seaspider/org/gnunet/seaspider/ExpressionDatabaseHandler.java index 5886fc90b..a94f63e77 100644 --- a/src/monkey/seaspider/org/gnunet/seaspider/ExpressionDatabaseHandler.java +++ b/src/monkey/seaspider/org/gnunet/seaspider/ExpressionDatabaseHandler.java @@ -8,8 +8,13 @@ import org.tmatesoft.sqljet.core.table.ISqlJetTable; import org.tmatesoft.sqljet.core.table.SqlJetDb; public class ExpressionDatabaseHandler { - - private static SqlJetDb db = null; + + private static final boolean DEBUG = false; + + private static SqlJetDb db; + + private static ISqlJetTable table; + public static void createExpressionDatabase(String databasePath) { String createTableQuery = "CREATE TABLE Expression ( expr_ID INT NOT NULL PRIMARY KEY , " + @@ -31,6 +36,8 @@ public class ExpressionDatabaseHandler { } /* Create table Expression */ db.createTable(createTableQuery); + db.beginTransaction(SqlJetTransactionMode.WRITE); + table = db.getTable("Expression"); } catch (SqlJetException e) { e.printStackTrace(); @@ -41,6 +48,7 @@ public class ExpressionDatabaseHandler { public static void closeDatabase() { try { + db.commit(); db.close(); } catch (SqlJetException e) { e.printStackTrace(); @@ -55,24 +63,15 @@ public class ExpressionDatabaseHandler { return; if (expressionSyntax.startsWith("\"")) return; - if (false) + if (DEBUG) System.out.println (fileName + ":[" + startLineNo + "-" + endLineNo + "]: " + expressionSyntax); - if (true) - return; if (db == null) { System.out.println("Error:Database handle is not initialized. Program will exit now!"); System.exit(1); } - ISqlJetTable table; try { - table = db.getTable("Expression"); - db.beginTransaction(SqlJetTransactionMode.WRITE); - try { - table.insert(fileName, expressionSyntax, startLineNo, endLineNo); - } finally { - db.commit(); - } + table.insert(fileName, expressionSyntax, startLineNo, endLineNo); } catch (SqlJetException e) { e.printStackTrace(); diff --git a/src/monkey/seaspider/org/gnunet/seaspider/Seaspider.java b/src/monkey/seaspider/org/gnunet/seaspider/Seaspider.java index f07413657..15ad2571c 100644 --- a/src/monkey/seaspider/org/gnunet/seaspider/Seaspider.java +++ b/src/monkey/seaspider/org/gnunet/seaspider/Seaspider.java @@ -38,11 +38,11 @@ public class Seaspider { } }; - /* File filter to get only source and header files */ + /* File filter to get only source files and no test cases */ FileFilter sourceFilter = new FileFilter() { public boolean accept(File file) { String fileName = file.getName(); - return fileName.endsWith(".c"); + return fileName.endsWith(".c") && ! fileName.startsWith("test_"); } };