Solved

Select SQL Prepared statement

Posted on 2004-04-22
5
175 Views
Last Modified: 2010-05-18
When I click on the button to retrieve information from my database using the below.  Nothing happens, no error message at all!!!  Can anyone help??  The listener is below this method

public void viewmemberSQL(){
                  
                        try     {

             Statement st = con.createStatement();
PreparedStatement ps5 = con.prepareStatement( "Select * from Members where Memberid = ?" );

          ps5.setInt(1, memberid2);
         

          ResultSet rs = ps5.executeQuery();
                      while (rs.next()) {
    viewmembertfield1.setText(rs.getString(1));
    viewmembertfield2.setText(rs.getString(2));
    viewmembertfield3.setText(rs.getString(3));
    viewmembertfield4.setText(rs.getString(4));
    viewmembertfield5.setText(rs.getString(5));
    viewmembertfield6.setText(rs.getString(6));
    viewmembertfield7.setText(rs.getString(7));
    viewmembertfield8.setText(rs.getString(8));
    viewmembertfield9.setText(rs.getString(9));
    viewmembertfield10.setText(rs.getString(10));
   
}
         st.close();
            con.close();

                           }

     catch (Exception e) {
            System.err.println("Got an exception! ");
            System.err.println(e.getMessage());


                    }

     finally{

          if(con != null)
          {
               try{
                    con.close();
          }

          catch(Exception ignored) {}
          }
          }

          }





                        class MemberviewDetails implements ActionListener
     {
         
**********************************************************************

      public MemberviewDetails() {

             }
          public void actionPerformed(ActionEvent e)
          {

         
         
          memberid = Integer.parseInt(viewmembertfield11.getText());
          viewmemberSQL();          

            }
   
  }
     
*************************************************************************

viewmemberbutton2 = new JButton("OK");
viewmemberbutton2.addActionListener(new MemberviewDetails());
0
Comment
Question by:mcowman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 10892279
Most likely you're getting no rows returned. Put a println in your while loop - if it doesn't print then you haven't
0
 

Author Comment

by:mcowman
ID: 10892670
Found the mistake, in the listener memberid is


          memberid = Integer.parseInt(viewmembertfield11.getText());



while in the statement is



          ps5.setInt(1, memberid2);
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10892690
OK - you can have the Q deleted if you want
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 11702956
PAQed, with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question