Ah, so you are putting all of the rows in one HashMap, I guess you said that before. I guess I choose the way I did for convenient sake otherwise I am going to be iterating over the keySet and my logic would know it should go to the next row in the display when column_name1 comes back around.
fair enough, there is more than one way to skin a cat. Bryan ----- Original Message ----- From: "Adrian Janssen" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, February 27, 2003 4:06 AM Subject: Re: preparedStatement > Sorry, I did not mean to send directly to just you, but something like > this: > > int rowNum = 0; > columnsAndRows = new HashMap(); > while(myquery.next()) > { > // increment the row number > rowNum++; > > // add all columns from this row to the Map. > columnsAndRows.put ( "column_name1**" + rowNum, myquery.getObject(1) ); > columnsAndRows.put ( "column_name2**" + rowNum, myquery.getObject(2) ); > columnsAndRows.put ( "column_name3**" + rowNum, myquery.getObject(3) ); > //........... and so on. > } > > > > > and then to fetch for eg: column_name2 on row 23 you do. > > Object o = columnsAndRows.get("column_name3**23"); > > The nice thing about this is that there is only one HashMap involved instead > of MANY, and no ArrayList is needed. Also note that as HashMap's get bigger > they do not get slower. > > Cheers > Adrian > > > > -----Original Message----- > > From: Bryan LaPlante [SMTP:[EMAIL PROTECTED] > > Sent: 27 February 2003 11:28 > > To: Adrian Janssen > > Subject: Re: preparedStatement > > > > I am not sure what you mean, the row23 is throwing me off a bit. Do you > > mean > > that your key would be the column names and the value would be a delimited > > string of values? > > > > ----- Original Message ----- > > From: "Adrian Janssen" <[EMAIL PROTECTED]> > > To: "'Bryan LaPlante'" <[EMAIL PROTECTED]> > > Sent: Thursday, February 27, 2003 2:53 AM > > Subject: RE: preparedStatement > > > > > > > A much less complicated approach is to just use one HashMap with a > > compound > > > key e.g."col_name1^^row23". > > > > > > > > > > -----Original Message----- > > > > From: Bryan LaPlante [SMTP:[EMAIL PROTECTED] > > > > Sent: 27 February 2003 06:18 > > > > To: [EMAIL PROTECTED] > > > > Subject: Re: preparedStatement > > > > > > > > What I have been doing in my custom tags could also apply to any query > > > > output situation. The following is in lieu of declaring your query > > > > TYPE_SCROLL_INSENSITIVE and then calling myquery.first() to reset the > > > > cursor back to the first row. > > > > > > > > //Create an ArrayList Of HashMaps > > > > ArrayList rows = new ArrayList(); > > > > HashMap columns = null > > > > > > > > //as you output the query the first time also add it to the above > > > > structures. > > > > while(myquery.next()){ > > > > columns = new HashMap(); > > > > colums.put("column_name1",myquery.getObject(1)); > > > > colums.put("column_name2",myquery.getObject(2)); > > > > //........... and so on. > > > > // add the columns to a row > > > > rows.add(columns) > > > > } > > > > > > > > > > > > // then loop through your structure like so. > > > > > > > > rowIter = rows.iterator(); > > > > while(rowIter.hasNext()){ > > > > columns = rowIter.next(); > > > > thismap.get("column_name1"); > > > > thismap.get("column_name2"); > > > > } > > > > //.......... and so on. > > > > > -- > > It is the strict policy of Truworths that its e-mail facility and all > e-mail communications emanating therefrom, should be utilised for > business purposes only and should conform to high professional and > business standards. Truworths has stipulated certain regulations in > terms whereof strict guidelines relating to the use and content of > e-mail communications are laid down. The use of the Truworths e-mail > facility is not permitted for the distribution of chain letters or > offensive mail of any nature whatsoever. Truworths hereby distances > itself from and accepts no liability in respect of the unauthorised > use of its e-mail facility or the sending of e-mail communications > for other than strictly business purposes. Truworths furthermore > disclaims liability for any unauthorised instruction for which > permission was not granted. Truworths Limited accepts no liability > for any consequences arising from or as a result of reliance on this > message unless it is in respect of bona fide Truworths business for > which proper authorisation has been granted. > > Any recipient of an unacceptable communication, a chain letter or > offensive material of any nature is requested to notify the Truworths > e-mail administrator ([EMAIL PROTECTED]) immediately in order that > appropriate action can be taken against the individual concerned. > > =========================================================================== > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". > For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". > > Some relevant archives, FAQs and Forums on JSPs can be found at: > > http://java.sun.com/products/jsp > http://archives.java.sun.com/jsp-interest.html > http://forums.java.sun.com > http://www.jspinsider.com > =========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant archives, FAQs and Forums on JSPs can be found at: http://java.sun.com/products/jsp http://archives.java.sun.com/jsp-interest.html http://forums.java.sun.com http://www.jspinsider.com