I want to get data from my DB where is LocalDateTime equals to LocalDateTime in get request.
@Override
public List<Timeslot> getAllAvailable(LocalDateTime localDateTime) {
return jdbcTemplate.query("select * from timeslot where day = ?", TIMESLOT_ROW_MAPPER);
}
Timeslot table code:
CREATE TABLE "timeslot" (
"timeslot_id" serial,
"day" date NOT NULL,
"start_time" TIME NOT NULL,
"end_time" TIME NOT NULL,
"user_id" serial NOT NULL,
"is_recorded" boolean,
CONSTRAINT "timeslot_pk" PRIMARY KEY ("timeslot_id")
);
Controller code:
@GetMapping("/allAvailable")
public List<Timeslot> getAllAvailable(@RequestParam("day") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime day) {
return userService.allAvailable(day);
}
But when I did this request result in console is: org.postgresql.util.PSQLException: ERROR: syntax error at end of input. How do i change sql request code to fix this error? Should I use PrepareStatement or something else?
jdbcTemplate.query(...). Probably need to use this overloaded version.ERROR: bind message supplies 0 parameters, but prepared statement "" requires 1. LocalDateTime isn't being passed in SQL requests.