#Getting time in queryforobject jdbctemplate

3 messages · Page 1 of 1 (latest)

hollow lodge
#
    @Override
    public Time getEndTimeByDoctorIdDate(int doctorId, Date officeDate) {
        Time endTime;
        String sql = "SELECT end_time FROM doctor_time JOIN doctor ON doctor_time.doctor_id=doctor.doctor_id WHERE doctor.doctor_id = ? AND doctor_time.office_date = ?;" ;
        try { 
            endTime = jdbcTemplate.queryForObject(sql, Time.class, doctorId, officeDate);
        } catch (EmptyResultDataAccessException e) {
            // Handle the case when no results are found
            endTime = java.sql.Time.valueOf("7:00:00");
        }
        return endTime;
    }

Doesn't seem to work? Can anyone help with why? I'm trying to pull a time in the format of "08:00:00" from postgres database.

wet socketBOT
#

This post has been reserved for your question.

Hey @hollow lodge! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.