@Override
    public User findById(int id) {
        User user = null;
        try {
            connection = getConnection();
            ptmt = connection.prepareStatement(QUERY_SELECT + " WHERE id =?;");
            ptmt.setInt(1, id);
            resultSet = ptmt.executeQuery();
            resultSet.next();
            user = new User(id);
            user.setActive(resultSet.getBoolean(ACTIVE));
            user.setEmail(resultSet.getString(EMAIL));
            user.setLastName(resultSet.getString(LAST_NAME));
            user.setLogin(resultSet.getString(LOGIN));
            user.setName(resultSet.getString(NAME));
            user.setPassword(resultSet.getString(PASSWORD));
            user.setBirthday(resultSet.getDate(BIRTHDAY));
            user.setDateOfRegistration(resultSet.getDate(DATE_OF_REGISTRATION));

        } catch (SQLException ex) {
            Logger.getLogger(UserDAO.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 user;
    }