Friday, October 26, 2012

Code used in video "Java prog#20.How to search a particular data inSQLite (MySql) Database in Netbeans java jtable"

Here I am providing the downloadable code link of  the java code I have used in the video
 "Java prog#20.How to search a particular data inSQLite (MySql) Database in Netbeans java jtable"  of my YouTube channel ProgrammingKnowledge

Click Link to watch the video LINK

This code below is for the txt_searchKeyReleased method action perform


  private void txt_searchKeyReleased(java.awt.event.KeyEvent evt) {                  

  try{
                 
               
              String sql3 ="select * from Empoyeeinfo where name =?" ;
              
              pst=conn.prepareStatement(sql3);
               pst.setString(1, txt_search.getText());
               
               rs=pst.executeQuery();
               if(rs.next()){
               String add1=rs.getString("empoyeeid");
               txt_Empoyeeid.setText(add1);
               String add2=rs.getString("name");
              txt_name.setText(add2);
               String add3=rs.getString("surname");
               txt_surname.setText(add3);
               String add4=rs.getString("age");
               combo_age.setSelectedItem(add4);
      
               }
               

               
    }
           catch(Exception e)
    {
           JOptionPane.showMessageDialog(null, e);

    }


                     
}

5 comments:

  1. try{

    String value1=txt_eid.getText();
    String value2=txt_op.getText();
    String value3=txt_np.getText();
    String value4=txt_conp.getText();

    String sql="update Employeeinfo set password='"+value4+"' where employeeid ='"+value1+"'";
    pst=conn.prepareStatement(sql);
    rs=pst.executeQuery();

    while(rs.next()){
    String p1 = rs.getString(6);
    if(value2.equals(p1)) {
    if(value3.equals(value4)) {


    pst.setString(6,value4);
    pst.execute();
    JOptionPane.showMessageDialog(null, "Password Changed");

    }
    }

    }
    }
    catch(Exception e){
    JOptionPane.showMessageDialog(null,e);
    }
    finally {
    try{
    rs.close();
    pst.close();
    } catch(Exception e){

    }
    }




    output of the program is query does not return result plz tell me the error and how to take corrective action !! plz tell me i m waiting

    ReplyDelete
  2. Replies
    1. what is the error that you are getting??

      Delete
  3. Sir, what is "PST", it didn't work in my netbeans, it say can't find symbol ?

    ReplyDelete
  4. pst is a variable for preparedstatement so u can name it whatever you want it to be e.g pst,pstat,prestat,ps anything

    ReplyDelete