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.

----- Original Message -----
From: "Balamurugan . R" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, February 26, 2003 9:40 PM
Subject: Re: preparedStatement


> Use seprate statement for each resultset
>
> "Shahata, Ash" wrote:
>
> > I tried this already, but unfortuanltly I get the same result... the
problem
> > seems that rs2 can not be looped through more than once! Is this how
result
> > sets react in general, would I be able to loop through a resultset more
than
> > once?
> >
> > -----Original Message-----
> > From: Mathias Höggren [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, February 26, 2003 11:13 AM
> > To: [EMAIL PROTECTED]
> > Subject: SV: preparedStatement
> >
> > Hi!
> >
> > I strongly suspect your problem is right here:
> > if(val1 == val2){
> >
> > Try this instead:
> > if (val1.equals(val2)) {
> >
> > Brgds
> > Mathias
> >
> > -----Ursprungligt meddelande-----
> > Från: A mailing list about Java Server Pages specification and reference
> > [mailto:[EMAIL PROTECTED] Shahata, Ash
> > Skickat: den 26 februari 2003 12:09
> > Till: [EMAIL PROTECTED]
> > Ämne: Re: preparedStatement
> >
> > I think I figured it out where the problem is, it'a not from the code
that I
> > sent it's to do with the rs.next! However I still couldnt fix it. The
value
> > of tname is passed correctly and when I retireve it on its own, it works
> > fine. Here's the part of the code that is causing the problem:
> >
> >     while (rs.next()){
> >         out.println("Inside rs");
> >         while(rs2.next()){
> >                 out.println("Inside rs2");
> >                 String val1 = rs.getString(2);
> >                 String val2 = rs2.getString(2);
> >                 if(val1 == val2){
> >                         out.println("Inside IF");
> >                         String id2 = rs2.getString(1);
> >                         out.println("Sybase Customer Name = " +
> > rs2.getString("swName"));
> >                         out.println(" | id = " + id2 + "<br>");
> >                 }//if
> >         }//while(rs2.next())
> >    }//while(rs.next())
> >
> > I'm looping through both result sets, expecting to see rs2 looping
several
> > times for every value of rs1, but here's what I grt from my println:
> >
> > These Records appear on both systems
> > Inside rs Inside rs2 Inside rs2 Inside rs2 Inside rs2 Inside rs2 Inside
rs2
> > Inside rs2 Inside rs Inside rs Inside rs
> >
> > Any idea why the loop is not functioning as expected?
> > Thanks
> >
> > -----Original Message-----
> > From: Pillai Jaideep, App Spec, SCS-SD [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, February 26, 2003 10:18 AM
> > To: [EMAIL PROTECTED]
> > Subject: Re: preparedStatement
> >
> > R U sure tname variable holds exactly the value U want ?
> >
> > -----Original Message-----
> > From: Shahata, Ash [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, February 26, 2003 5:50 PM
> > To: [EMAIL PROTECTED]
> > Subject: preparedStatement
> >
> > Hi there,
> > I'm getting stuck with the following procedure using prepared
statements..
> > it works just fine if I use a normal statement. I need to pass a
prepared
> > statement because I need to pass a valriable to the query. It does not
> > return any records!
> >
> >    Statement stmt = con1.createStatement();
> >    String query = "Select * from SW_Customer where swName = ?";
> >    PreparedStatement ps = con1.prepareStatement(query);
> >    ps.setString(1,tname);
> >    ResultSet rs = ps.executeQuery();
> >    while (rs.next()){
> >       String name = rs.getString(1);
> >       out.println("Value of field = " + rs.getString("swName"));
> >       out.println("Value of field = " + name);
> >                 }
> >
> > Any help will be appreciated
> >
> > Thanks
> >
> >
===========================================================================
> > 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
> >
> >
===========================================================================
> > 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
> >
> > 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
>

===========================================================================
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

Reply via email to