SqliteDB: bug fixes
[org.ibex.mail.git] / src / org / ibex / mail / SqliteDB.java
index 900e07c..42a1755 100644 (file)
@@ -43,8 +43,10 @@ public class SqliteDB {
             conn = DriverManager.getConnection("jdbc:sqlite:"+filename);
             conn.prepareStatement("PRAGMA auto_vacuum = 1").executeUpdate();
             conn.prepareStatement("VACUUM").executeUpdate();
+
             // until we have better assurances about locking on network filesystems...
-            conn.prepareStatement("PRAGMA locking_mode = EXCLUSIVE").executeUpdate();
+            conn.prepareStatement("PRAGMA locking_mode = EXCLUSIVE").executeQuery();
+
             conn.prepareStatement("PRAGMA temp_store = MEMORY").executeUpdate();
             conn.prepareStatement("PRAGMA page_size=4096").executeUpdate();
             conn.prepareStatement("PRAGMA cache_size=2000").executeUpdate();
@@ -72,15 +74,12 @@ public class SqliteDB {
         private String reapColumn = null;
         private SqliteTable(String name, String schema) throws SQLException {
             this.name = name;
-            PreparedStatement ps = conn.prepareStatement("create table if not exists ?");
-            ps.setString(1, name+" "+schema);
+            PreparedStatement ps = conn.prepareStatement("create table if not exists " + name + " " + schema);
             ps.executeUpdate();
             tables.put(name, this);
         }
         public void createIndex(String name, String column) throws SQLException {
-            PreparedStatement ps = conn.prepareStatement("create index if not exists ? on ?");
-            ps.setString(1, name);
-            ps.setString(2, column);
+            PreparedStatement ps = conn.prepareStatement("create index if not exists "+name+" on "+column);
             ps.executeUpdate();
         }
         protected void reap(String reapColumn) {