1 17 package org.apache.servicemix.jdbc; 18 19 25 public class Statements { 26 27 private String tablePrefix = ""; 28 protected String storeTableName = "SM_STORE"; 29 30 protected String binaryDataType = "BLOB"; 31 protected String idDataType = "VARCHAR(48)"; 32 private String storeDataStatement; 33 private String updateDataStatement; 34 private String removeDataStatement; 35 private String findDataStatement; 36 private String findAllIdsStatement; 37 private String findAllDataStatement; 38 private String countStatement; 39 private String [] createSchemaStatements; 40 private String [] dropSchemaStatements; 41 42 public String [] getCreateSchemaStatements() { 43 if (createSchemaStatements == null) { 44 createSchemaStatements = new String [] { 45 "CREATE TABLE " + getFullStoreTableName() + "(" + "ID " + idDataType + " NOT NULL" 46 + ", DATA " + binaryDataType 47 + ", PRIMARY KEY ( ID ) )", 48 }; 49 } 50 return createSchemaStatements; 51 } 52 53 public String [] getDropSchemaStatements() { 54 if (dropSchemaStatements == null) { 55 dropSchemaStatements = new String [] { 56 "DROP TABLE " + getFullStoreTableName() + "", 57 }; 58 } 59 return dropSchemaStatements; 60 } 61 62 public String getStoreDataStatement() { 63 if (storeDataStatement == null) { 64 storeDataStatement = "INSERT INTO " + getFullStoreTableName() 65 + "(ID, DATA) VALUES (?, ?)"; 66 } 67 return storeDataStatement; 68 } 69 70 public String getUpdateDataStatement() { 71 if (updateDataStatement == null) { 72 updateDataStatement = "UPDATE " + getFullStoreTableName() + " SET DATA=? WHERE ID=?"; 73 } 74 return updateDataStatement; 75 } 76 77 public String getRemoveDataStatement() { 78 if (removeDataStatement == null) { 79 removeDataStatement = "DELETE FROM " + getFullStoreTableName() + " WHERE ID=?"; 80 } 81 return removeDataStatement; 82 } 83 84 public String getFindDataStatement() { 85 if (findDataStatement == null) { 86 findDataStatement = "SELECT DATA FROM " + getFullStoreTableName() + " WHERE ID=?"; 87 } 88 return findDataStatement; 89 } 90 91 public String getFindAllIdsStatement() { 92 if (findAllIdsStatement == null) { 93 findAllIdsStatement = "SELECT ID FROM " + getFullStoreTableName() 94 + " ORDER BY ID"; 95 } 96 return findAllIdsStatement; 97 } 98 99 public String getFindAllDataStatement() { 100 if (findAllDataStatement == null) { 101 findAllDataStatement = "SELECT ID, DATA FROM " + getFullStoreTableName() 102 + " WHERE ORDER BY ID"; 103 } 104 return findAllDataStatement; 105 } 106 107 public String getCountStatement() { 108 if (countStatement == null) { 109 countStatement = "SELECT COUNT(ID) FROM " + getFullStoreTableName(); 110 } 111 return countStatement; 112 } 113 114 public String getFullStoreTableName() { 115 return getTablePrefix() + getStoreTableName(); 116 } 117 118 121 public String getBinaryDataType() { 122 return binaryDataType; 123 } 124 125 129 public void setBinaryDataType(String messageDataType) { 130 this.binaryDataType = messageDataType; 131 } 132 133 136 public String getStoreTableName() { 137 return storeTableName; 138 } 139 140 144 public void setStoreTableName(String storeTableName) { 145 this.storeTableName = storeTableName; 146 } 147 148 151 public String getIdDataType() { 152 return idDataType; 153 } 154 155 159 public void setIdDataType(String msgIdDataType) { 160 this.idDataType = msgIdDataType; 161 } 162 163 166 public String getTablePrefix() { 167 return tablePrefix; 168 } 169 170 174 public void setTablePrefix(String tablePrefix) { 175 this.tablePrefix = tablePrefix; 176 } 177 178 public void setStoreDataStatement(String addMessageStatment) { 179 this.storeDataStatement = addMessageStatment; 180 } 181 182 public void setCreateSchemaStatements(String [] createSchemaStatments) { 183 this.createSchemaStatements = createSchemaStatments; 184 } 185 186 public void setDropSchemaStatements(String [] dropSchemaStatments) { 187 this.dropSchemaStatements = dropSchemaStatments; 188 } 189 190 public void setFindAllDataStatement(String findAllMessagesStatment) { 191 this.findAllDataStatement = findAllMessagesStatment; 192 } 193 194 public void setFindDataStatement(String findMessageStatment) { 195 this.findDataStatement = findMessageStatment; 196 } 197 198 public void setRemoveDataStatement(String removeMessageStatment) { 199 this.removeDataStatement = removeMessageStatment; 200 } 201 202 public void setUpdateDataStatement(String updateMessageStatment) { 203 this.updateDataStatement = updateMessageStatment; 204 } 205 206 public void setFindAllIdsStatement(String findAllIdsStatement) { 207 this.findAllIdsStatement = findAllIdsStatement; 208 } 209 210 public void setCountStatement(String getCountStatement) { 211 this.countStatement = getCountStatement; 212 } 213 214 } | Popular Tags |