what problem u r facing with this piece of code

           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);
                        }





> -----Original Message-----
> From: Shahata, Ash [SMTP:[EMAIL PROTECTED]
> Sent: Wednesday, February 26, 2003 3:20 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
*********************************************************************
Disclaimer: The information in this e-mail and any attachments is
confidential / privileged. It is intended solely for the addressee or
addressees. If you are not the addressee indicated in this message, you may
not copy or deliver this message to anyone. In such case, you should destroy
this message and kindly notify the sender by reply email. Please advise
immediately if you or your employer does not consent to Internet email for
messages of this kind.
*********************************************************************

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