aboutsummaryrefslogtreecommitdiff
path: root/src/monkey
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-10-27 14:41:20 +0000
committerChristian Grothoff <christian@grothoff.org>2010-10-27 14:41:20 +0000
commit39d3a23b251dbfda4652c75699fc3d434a7df52f (patch)
tree735bd70246747aa42c1a8dbebd1708fefd74db3b /src/monkey
parentb229a887dfd73dcb2e8bd3d54dc21878fa189ddc (diff)
downloadgnunet-39d3a23b251dbfda4652c75699fc3d434a7df52f.tar.gz
gnunet-39d3a23b251dbfda4652c75699fc3d434a7df52f.zip
proper transactions
Diffstat (limited to 'src/monkey')
-rw-r--r--src/monkey/seaspider/org/gnunet/seaspider/ExpressionDatabaseHandler.java25
-rw-r--r--src/monkey/seaspider/org/gnunet/seaspider/Seaspider.java4
2 files changed, 14 insertions, 15 deletions
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;
8import org.tmatesoft.sqljet.core.table.SqlJetDb; 8import org.tmatesoft.sqljet.core.table.SqlJetDb;
9 9
10public class ExpressionDatabaseHandler { 10public class ExpressionDatabaseHandler {
11 11
12 private static SqlJetDb db = null; 12 private static final boolean DEBUG = false;
13
14 private static SqlJetDb db;
15
16 private static ISqlJetTable table;
17
13 18
14 public static void createExpressionDatabase(String databasePath) { 19 public static void createExpressionDatabase(String databasePath) {
15 String createTableQuery = "CREATE TABLE Expression ( expr_ID INT NOT NULL PRIMARY KEY , " + 20 String createTableQuery = "CREATE TABLE Expression ( expr_ID INT NOT NULL PRIMARY KEY , " +
@@ -31,6 +36,8 @@ public class ExpressionDatabaseHandler {
31 } 36 }
32 /* Create table Expression */ 37 /* Create table Expression */
33 db.createTable(createTableQuery); 38 db.createTable(createTableQuery);
39 db.beginTransaction(SqlJetTransactionMode.WRITE);
40 table = db.getTable("Expression");
34 } 41 }
35 catch (SqlJetException e) { 42 catch (SqlJetException e) {
36 e.printStackTrace(); 43 e.printStackTrace();
@@ -41,6 +48,7 @@ public class ExpressionDatabaseHandler {
41 public static void closeDatabase() 48 public static void closeDatabase()
42 { 49 {
43 try { 50 try {
51 db.commit();
44 db.close(); 52 db.close();
45 } catch (SqlJetException e) { 53 } catch (SqlJetException e) {
46 e.printStackTrace(); 54 e.printStackTrace();
@@ -55,24 +63,15 @@ public class ExpressionDatabaseHandler {
55 return; 63 return;
56 if (expressionSyntax.startsWith("\"")) 64 if (expressionSyntax.startsWith("\""))
57 return; 65 return;
58 if (false) 66 if (DEBUG)
59 System.out.println (fileName + ":[" + startLineNo + "-" + endLineNo + "]: " + expressionSyntax); 67 System.out.println (fileName + ":[" + startLineNo + "-" + endLineNo + "]: " + expressionSyntax);
60 if (true)
61 return;
62 if (db == null) { 68 if (db == null) {
63 System.out.println("Error:Database handle is not initialized. Program will exit now!"); 69 System.out.println("Error:Database handle is not initialized. Program will exit now!");
64 System.exit(1); 70 System.exit(1);
65 } 71 }
66 72
67 ISqlJetTable table;
68 try { 73 try {
69 table = db.getTable("Expression"); 74 table.insert(fileName, expressionSyntax, startLineNo, endLineNo);
70 db.beginTransaction(SqlJetTransactionMode.WRITE);
71 try {
72 table.insert(fileName, expressionSyntax, startLineNo, endLineNo);
73 } finally {
74 db.commit();
75 }
76 } 75 }
77 catch (SqlJetException e) { 76 catch (SqlJetException e) {
78 e.printStackTrace(); 77 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 {
38 } 38 }
39 }; 39 };
40 40
41 /* File filter to get only source and header files */ 41 /* File filter to get only source files and no test cases */
42 FileFilter sourceFilter = new FileFilter() { 42 FileFilter sourceFilter = new FileFilter() {
43 public boolean accept(File file) { 43 public boolean accept(File file) {
44 String fileName = file.getName(); 44 String fileName = file.getName();
45 return fileName.endsWith(".c"); 45 return fileName.endsWith(".c") && ! fileName.startsWith("test_");
46 } 46 }
47 }; 47 };
48 48