@Override
    public Task findById(int id) {
        Task task = null;
        try {
            connection = getConnection();
            ptmt = connection.prepareStatement(QUERY_SELECT + "WHERE idtask=?;");
            resultSet = ptmt.executeQuery();
            resultSet.next();
            task = new Task(id);
            task.setTitle(resultSet.getString(TITLE));
            task.setDescription(resultSet.getString(DESCRIPTION));
            task.setIdOwner(resultSet.getInt(ID_OWNER));
            task.setIdExecutor(resultSet.getInt(ID_EXECUTOR));
            task.setActive(resultSet.getBoolean(ACTIVE));
            task.setDone(resultSet.getBoolean(DONE));
        } catch (SQLException ex) {
            Logger.getLogger(TaskDAO.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            try {
                if (ptmt != null) {
                    ptmt.close();
                }
                if (connection != null) {
                    connection.close();
                }
                if (resultSet != null) {
                    resultSet.close();
                }
            } catch (SQLException ex) {
                Logger.getLogger(UserDAO.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        return task;
        
    }