Ребята, я решил эту проблему, но теперь у меня другая ошибка :) Мой метод возвращает ноль.первый sysout верный последний sysout нулевой
@Override
public Employee saveEmployee(Employee employee) throws SQLException {
System.out.println("Received emp: " + employee);
String sql = "";
Random random = new Random();
employee.setId(1990000000000L + random.nextInt(1000000000));
System.out.println(1990000000000L + random.nextInt(1000000000));
if (employee.getId() == null) {
sql = String.format(
"UPDATE employees SET idemployees = '%d' , firstName = '%s', lastName = '%s' ,birthDay = '%s' WHERE idemployees = '%d'",
employee.getId(), employee.getFirstName(), employee.getLastName(), employee.getBirthDay(),
employee.getId());
} else {
DateConvert convert = new DateConvert();
LocalDate dateToConvert = employee.getBirthDay();
System.out.println(DateConvert.convertToDateViaInstant(employee.getBirthDay()));
sql = String.format(
"INSERT INTO employees (idemployees,firstName,lastName,birthDay) VALUES ('%d','%s','%s','%s')",
employee.getId(), employee.getFirstName(), employee.getLastName(), employee.getBirthDay());
employee = getEmployee(employee.getId());
}
System.out.println(sql);
boolean rs = SendInsertQuery(sql);
System.out.println("saved employee" + employee);
return employee;
}
Received emp: Employee{id=232323233, firstName='Tarek', lastName='Abaza', birthDay=1990-01-04}
1990895219625
Thu Jan 04 00:00:00 CET 1990
INSERT INTO employees (idemployees,firstName,lastName,birthDay) VALUES ('1990500456506','Tarek','Abaza','1990-01-04')
Received emp: null