public List<Attachment> exportAttachments() { if (!this.running) return null; // get user configured column names and sql String colId = (String) this.properties.get(PROPKEY_ATTACHMENT_ID); String colThumb = (String) this.properties.get(PROPKEY_ATTACHMENT_THUMB); String colMessage = (String) this.properties.get(PROPKEY_ATTACHMENT_MESSAGE); String colName = (String) this.properties.get(PROPKEY_ATTACHMENT_NAME); String colHash = (String) this.properties.get(PROPKEY_ATTACHMENT_HASH); String table = (String) this.properties.get(PROPKEY_ATTACHMENT_TABLE); String rawSql = (String) this.properties.get(PROPKEY_ATTACHMENT_SQL); // update sql to reflect user configured column names String sql = rawSql.replaceAll("\\Q{" + PROPKEY_ATTACHMENT_ID + "}\\E", colId); sql = sql.replaceAll("\\Q{" + PROPKEY_ATTACHMENT_THUMB + "}\\E", colThumb); sql = sql.replaceAll("\\Q{" + PROPKEY_ATTACHMENT_MESSAGE + "}\\E", colMessage); sql = sql.replaceAll("\\Q{" + PROPKEY_ATTACHMENT_NAME + "}\\E", colName); sql = sql.replaceAll("\\Q{" + PROPKEY_ATTACHMENT_HASH + "}\\E", colHash); sql = sql.replaceAll("\\Q{" + PROPKEY_ATTACHMENT_TABLE + "}\\E", table); Vector<Attachment> attachments = new Vector<Attachment>(); ResultSet data = null; try { data = sql(sql); while (data.next()) { // get each category Attachment attachment = new Attachment(); attachment.id = data.getString(colId); attachment.thumb = data.getString(colThumb); attachment.message = data.getString(colMessage); attachment.name = encode(data.getBytes(colName)); attachment.hash = data.getString(colHash); saveAttachmentWithId(attachment); attachments.add(attachment); } } catch (SQLException e) { log.error("Could not export Attachments with sql: " + sql); e.printStackTrace(); return null; } return attachments; }