public static void sendTaskToDB(JSONToQuery incomingJSON) { try { Date dt = new java.util.Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String currentTime = sdf.format(dt); String czas_wyslania = ""; if (incomingJSON.getSend_time().isEmpty()) { czas_wyslania = currentTime; } else { czas_wyslania = incomingJSON.getSend_time(); } String query = "INSERT INTO `sms`.`tasks` (`phone_number`, `message`, `sender`, `send_time`) VALUES ('" + incomingJSON.getNumber() + "', '" + incomingJSON.getMessage() + "', '" + incomingJSON.getUser() + "', '" + czas_wyslania + "')"; System.out.println("-> Do bazy: " + incomingJSON.toString()); dba.writeDataBase(query); // notify(); } catch (ParseException ex) { Logger.getLogger(BuforZadan.class.getName()).log(Level.SEVERE, null, ex); } catch (Exception ex) { Logger.getLogger(BuforZadan.class.getName()).log(Level.SEVERE, null, ex); } }