Solved

Select SQL Prepared statement

Posted on 2004-04-22
5
159 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
  • 2
5 Comments
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
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
Comment Utility
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
Comment Utility
OK - you can have the Q deleted if you want
0
 

Accepted Solution

by:
modulo earned 0 total points
Comment Utility
PAQed, with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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 second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

744 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now