@Override
    public void updateRoom(Room room) {
        //throw new UnsupportedOperationException("Not supported yet.");
        
        if(room == null) {
            throw new IllegalArgumentException("Room is null");
        }
        
        if(room.getId() == null) {
            throw new IllegalArgumentException("ID of room must be set");
        }
        
        if(room.getId() <= 0L) {
            throw new IllegalArgumentException("ID of room must be a positive integer");
        }
        
        validate(room);
        
        Long tmp = getRoomWithGivenNumber(room.getNumber());
        if(tmp != null && tmp != room.getId()) { // exists room with different ID but same number
            // ID cannot be changed
            throw new IllegalArgumentException("Another room with given number "
                    + "(and different ID) already exists");
        }
        
        /*
        if(room.getNote() == null) {
            room.setNote("");
        }
        */
        
        checkDataSource();
        Connection conn = null;
        PreparedStatement st = null;
        try {
            conn = dataSource.getConnection();
            conn.setAutoCommit(false);
            st = conn.prepareStatement(
                    "UPDATE room SET capacity=?,floor=?,number=?,note=? " + 
                    "WHERE id = ?");
            st.setInt(1, room.getCapacity());
            st.setInt(2, room.getFloor());
            st.setInt(3, room.getNumber());
            st.setString(4, room.getNote());
            st.setLong(5, room.getId());
            
            /*
            int updatedRows = st.executeUpdate();
            if (updatedRows != 1) {
                throw new ServiceFailureException("Internal Error: More rows "
                        + "updated when trying to update room " + room);
            }
            */
            int count = st.executeUpdate();
            DBUtils.checkUpdatesCount(count, room, false);
            conn.commit();
        } catch (SQLException ex) {
            String msg = "Error when updating room " + room.toString();
            logger.log(Level.SEVERE, msg, ex);
            throw new ServiceFailureException(msg, ex);
        } finally {
            /*
            if (st != null) {
                try {
                    st.close();
                } catch (SQLException ex) {
                    logger.log(Level.SEVERE, null, ex);
                }
            }
            */
            DBUtils.doRollbackQuietly(conn);
            DBUtils.closeQuietly(conn, st);
        }
    }