Hello,
I'm having issues with my code, I'm using simpleJDBCinsert in order to create new entry to mt db. But when I run my code, it freezes.
Thank you for your help.
@Override public void createMission(Mission c) { SimpleJdbcInsert createMiss = new SimpleJdbcInsert(dataSource).withTableName("mission").usingGeneratedKeyColumns("id"); Map<String, Object> parameters = new HashMap<>(5); parameters.put("Mission_Name", c.getName()); parameters.put("Mission_Started", c.getStart()); parameters.put("Location", c.getLocation()); parameters.put("Mission_End", c.getEnd()); Number id = createMiss.executeAndReturnKey(parameters); c.setId(id.longValue()); }
here is my simplejdbc query
btnAddMission.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.print("Enter name of the mission: "); Scanner scan = new Scanner(System.in); String name = scan.nextLine(); System.out.print("Enter the Date of the mission: "); String date = scan.nextLine(); Date start = null; try { start = new SimpleDateFormat("yyyy/MM/dd" ).parse(date); } catch (ParseException e1) { e1.printStackTrace(); // } System.out.print("Enter the location: "); String location = scan.nextLine(); System.out.print("Enter the exparation time: "); String end = scan.nextLine(); Date endD = null; try { endD = new SimpleDateFormat("yyyy/ MM/dd").parse(end); } catch (ParseException e1) { e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } //Long id, String name, String location,Date start,Date end MissionManagerImpl miss = new MissionManagerImpl(); Mission mission = new Mission((long) 0, name, location, start, endD); miss.createMission(mission); } });