public class NoteTagsTable {\r
private final ApplicationLogger logger;\r
DatabaseConnection db;\r
+ NSqlQuery getNoteTagsQuery;\r
\r
\r
// Constructor\r
public List<String> getNoteTags(String noteGuid) {\r
if (noteGuid == null)\r
return null;\r
- boolean check;\r
List<String> tags = new ArrayList<String>();\r
\r
- NSqlQuery query = new NSqlQuery(db.getConnection());\r
- check = query.exec("Select "\r
- +"TagGuid from NoteTags where noteGuid = '" +noteGuid +"'");\r
- if (!check) {\r
+ if (getNoteTagsQuery == null)\r
+ prepareGetNoteTagsQuery();\r
+ \r
+ getNoteTagsQuery.bindValue(":guid", noteGuid);\r
+ if (!getNoteTagsQuery.exec()) {\r
logger.log(logger.EXTREME, "NoteTags SQL select has failed.");\r
- logger.log(logger.MEDIUM, query.lastError());\r
+ logger.log(logger.MEDIUM, getNoteTagsQuery.lastError());\r
return null;\r
}\r
- while (query.next()) {\r
- tags.add(query.valueString(0));\r
+ while (getNoteTagsQuery.next()) {\r
+ tags.add(getNoteTagsQuery.valueString(0));\r
} \r
return tags;\r
}\r
+ void prepareGetNoteTagsQuery() {\r
+ getNoteTagsQuery = new NSqlQuery(db.getConnection());\r
+ getNoteTagsQuery.prepare("Select TagGuid from NoteTags where noteGuid = :guid");\r
+ }\r
// Get a note tags by the note's Guid\r
public List<NoteTagsRecord> getAllNoteTags() {\r
List<NoteTagsRecord> tags = new ArrayList<NoteTagsRecord>();\r