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

Reply via email to