Solved

Select SQL Prepared statement

Posted on 2004-04-22
5
160 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
basic hardware to learn oop advanced design patterns 3 88
reasons why a "inside Menu" would not appear for a web server 6 56
xampp tool 12 30
use lov values 2 38
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

863 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

27 Experts available now in Live!

Get 1:1 Help Now