public void writeToDB() throws InterruptedException, SQLException { while (!reactants.isEmpty() || FileParserObserver.INSTANCE.getFileParserStatus()) { Reactant reactant = getRecord(); logManager.writeLog("DBWriter", reactant.getUniqueID()); executePreparedStatement(reactant); } }
private String createQueryString(Reactant reactant) { String field = "", value = ""; Hashtable<String, String> rec = reactant.getARecord(); for (String key : rec.keySet()) { field += "`" + key + "`, "; value += "'" + rec.get(key) + "', "; } field = field.substring(0, field.length() - 2); value = value.substring(0, value.length() - 2); String insertRecord = "INSERT INTO " + Helpers.DB_NAME.toString() + "." + Helpers.TABLE_NAME.toString() + "(" + field + " )" + " VALUES (" + value + " )"; return insertRecord; }