Code example for RowSet

Methods: absolutegetObjectgetMaxRows

0
	} 
    
	public int getRowCount() { 
		int count = 0;
		try { 
			count = rowSet.getMaxRows();
		} catch (Exception e) {
			e.printStackTrace();
		} 
		return count;
	} 
    
	protected Vector getKeyForItem(int rowIndex) {
		return getKeyForItem(rowIndex,true);
	} 
    
	protected Vector getKeyForItem(int rowIndex,boolean includeNotKeyColumn) {
		Vector<Object> key = new Vector<Object>();
		for(int i=0;i<getColumnCount();i++) {
			if(!includeNotKeyColumn) {
				// Add only if key 
				if(isKey(i)) key.add(getValueAt(rowIndex,i));
			} else { 
				// Always add 
				key.add(getValueAt(rowIndex,i));
			} 
		} 
		return key;
	} 
    
	protected Vector getSelectedItem() {
		return getKeyForItem(this.selectedItemIndex);
	} 
    
	protected Vector getSelectedItem(boolean includeNotKeyColumn) {
		return getKeyForItem(this.selectedItemIndex,includeNotKeyColumn);
	}    
    
	protected String getSelectedItemText() {
		return(this.selectedItemText);
	} 
    
	protected void setSelectedItemIndex(int selectedItemIndex) {
		this.selectedItemIndex=selectedItemIndex;
		boolean loop =true;
		int i=0;
		if(visibleColumnName==null) {
			// The visible column name was not defined, display the first non key column found 
			while(i<getColumnCount() && loop) {
				if(!table.getColumn(i).isKeyColumn()) {
					selectedItemText=getValueAt(selectedItemIndex,i).toString();
					loop=false;
				} 
				i++;
			} 
		} else { 
			// The visible column name was defined 
			while(i<getColumnCount() && loop) { 
				if(table.getColumn(i).getColumnName().equals(visibleColumnName)) {
					this.selectedItemText=getValueAt(selectedItemIndex,i).toString();
					loop=false;
				} 
				i++;
			} 
		} 
	} 
    
	protected boolean isKey(int columnIndex) {
		return table.getColumn(columnIndex).isKeyColumn();
	} 
	 
	protected void setSelectedItem(FormKeys formKeys) {
		 
	} 
		 
	protected void setSelectedItem(Vector key) {
		boolean loop=true;
		int z=0;
		int match=0;
		if(key.size()==table.getKeyColumnCount()) {
			for(int x=0;x<getRowCount() && loop;x++) {
				for(int y=0;y<getColumnCount() && loop;y++) {
					if(table.getColumn(y).isKeyColumn()) {
						if(getValueAt(x,y)!=null) {
							if(getValueAt(x,y) instanceof String) {
								if(((String)getValueAt(x,y)).trim().equals(((String)key.elementAt(z)).trim())) {
									match++;
								} 
							} else if(getValueAt(x,y).equals(key.elementAt(z))) {
								match++; 
							} 
						} 
						z++;
					} 
				} 
				if(match==table.getKeyColumnCount()) {
					// this row keys match, stop looping 
					loop=false;
					setSelectedItemIndex(x);
				} else { 
					// Not found, loop again 
					z=0;
					match=0;
				} 
			} 
		} else { 
			 
		} 
	} 
   	    
	public Class<?> getColumnClass(int columnIndex) {
		if(getRowCount()==0) { 
			return String.class;
		} 
		return getValueAt(0,columnIndex).getClass();
	} 
    
	public Object getValueAt(int rowIndex,int columnIndex) {
		Object value = null;
		try { 
			rowSet.absolute(rowIndex+1);
			value = rowSet.getObject(columnIndex+1);
		} catch (Exception ex) {
			logger.log(Level.WARNING,ex.getMessage());
			if(debug) ex.printStackTrace();
		} 
		return value;
Connect your IDE to all the code out there  Get Codota for Java