code: static public int extractIntResult(ResultSet rs, ResultSetMetaData rsmd, int index) throws Exception {
  
  		int count = rsmd.getColumnCount();
  		if( index > count || index < 1 ) {
  			throw new Exception("Invalid index");
  		}
  		
  		int type = rsmd.getColumnType(index);
  		switch (type) {
  			case java.sql.Types.INTEGER:
  			case java.sql.Types.SMALLINT:
  				return rs.getInt(index);
  		}
  
  		throw new Exception("Column type ("+type+") invalid for a string at index: "+index);
  	}
docs: This method returns an int result at a given index.
  @param stmt Statement that has been successfully executed
  @param index Index of expected column
  @return A value returned at the specified index
  @throws Exception If there is no column at index