Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Select SQL Prepared statement

Posted on 2004-04-22
5
Medium Priority
?
189 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

618 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