OSDN Git Service

Correct SQL due to database being split apart.
authorRandy Baumgarte <randy@fbn.cx>
Sat, 29 Jan 2011 21:05:46 +0000 (16:05 -0500)
committerRandy Baumgarte <randy@fbn.cx>
Sun, 30 Jan 2011 13:38:14 +0000 (08:38 -0500)
src/cx/fbn/nevernote/sql/NoteTable.java

index 53a0b0e..4e888f6 100644 (file)
@@ -546,9 +546,9 @@ public class NoteTable {
                \r
                \r
         NSqlQuery note = new NSqlQuery(db.getConnection());\r
-        NSqlQuery resources = new NSqlQuery(db.getConnection());\r
+        NSqlQuery resources = new NSqlQuery(db.getResourceConnection());\r
         NSqlQuery tags = new NSqlQuery(db.getConnection());\r
-        NSqlQuery words = new NSqlQuery(db.getConnection());\r
+        NSqlQuery words = new NSqlQuery(db.getIndexConnection());\r
         \r
                note.prepare("Delete from Note where guid=:guid");\r
                resources.prepare("Delete from NoteResources where noteGuid=:guid");\r
@@ -586,9 +586,9 @@ public class NoteTable {
        // Purge a note (actually delete it instead of just marking it deleted)\r
        public void hideExpungedNote(String guid, boolean needsSync) {\r
         NSqlQuery note = new NSqlQuery(db.getConnection());\r
-        NSqlQuery resources = new NSqlQuery(db.getConnection());\r
+        NSqlQuery resources = new NSqlQuery(db.getResourceConnection());\r
         NSqlQuery tags = new NSqlQuery(db.getConnection());\r
-        NSqlQuery words = new NSqlQuery(db.getConnection());\r
+        NSqlQuery words = new NSqlQuery(db.getIndexConnection());\r
         \r
                note.prepare("Update Note set isExpunged=true where guid=:guid");\r
                resources.prepare("Delete from NoteResources where noteGuid=:guid");\r
@@ -656,6 +656,8 @@ public class NoteTable {
        public void updateNoteGuid(String oldGuid, String newGuid) {\r
                boolean check;\r
         NSqlQuery query = new NSqlQuery(db.getConnection());\r
+        NSqlQuery resQuery = new NSqlQuery(db.getResourceConnection());\r
+        NSqlQuery wordQuery = new NSqlQuery(db.getIndexConnection());\r
                query.prepare("Update Note set guid=:newGuid where guid=:oldGuid");\r
 \r
                query.bindValue(":newGuid", newGuid);\r
@@ -676,21 +678,21 @@ public class NoteTable {
                        logger.log(logger.MEDIUM, query.lastError());\r
                }\r
                \r
-               query.prepare("Update words set guid=:newGuid where guid=:oldGuid");\r
-               query.bindValue(":newGuid", newGuid);\r
-               query.bindValue(":oldGuid", oldGuid);\r
-               query.exec();\r
+               wordQuery.prepare("Update words set guid=:newGuid where guid=:oldGuid");\r
+               wordQuery.bindValue(":newGuid", newGuid);\r
+               wordQuery.bindValue(":oldGuid", oldGuid);\r
+               wordQuery.exec();\r
                if (!check) {\r
                        logger.log(logger.MEDIUM, "Note guid update failed for Words.");\r
-                       logger.log(logger.MEDIUM, query.lastError());\r
+                       logger.log(logger.MEDIUM, wordQuery.lastError());\r
                }\r
-               query.prepare("Update noteresources set noteguid=:newGuid where noteguid=:oldGuid");\r
-               query.bindValue(":newGuid", newGuid);\r
-               query.bindValue(":oldGuid", oldGuid);\r
-               query.exec();\r
+               resQuery.prepare("Update noteresources set noteguid=:newGuid where noteguid=:oldGuid");\r
+               resQuery.bindValue(":newGuid", newGuid);\r
+               resQuery.bindValue(":oldGuid", oldGuid);\r
+               resQuery.exec();\r
                if (!check) {\r
                        logger.log(logger.MEDIUM, "Note guid update failed for noteresources.");\r
-                       logger.log(logger.MEDIUM, query.lastError());\r
+                       logger.log(logger.MEDIUM, resQuery.lastError());\r
                }\r
        }\r
        // Update a note\r
@@ -978,7 +980,7 @@ public class NoteTable {
        \r
        // Update a note resource by the hash\r
        public void updateNoteResourceGuidbyHash(String noteGuid, String resGuid, String hash) {\r
-               NSqlQuery query = new NSqlQuery(db.getConnection());\r
+               NSqlQuery query = new NSqlQuery(db.getResourceConnection());\r
 /*             query.prepare("Select guid from NoteResources where noteGuid=:noteGuid and datahash=:hex");\r
                query.bindValue(":noteGuid", noteGuid);\r
                query.bindValue(":hex", hash);\r