Java prog#21.Advanced search a particular data in SQLite (MySql) Database in Netbeans java jtable

Sdílet
Vložit
  • čas přidán 10. 05. 2012
  • -----------------Online Courses to learn---------------------------
    Java - bit.ly/2H6wqXk
    C++ - bit.ly/2q8VWl1
    AngularJS - bit.ly/2qebsLu
    Python - bit.ly/2Eq0VSt
    C- bit.ly/2HfZ6L8
    Android - bit.ly/2qaRSAS
    Linux - bit.ly/2IwOuqz
    AWS Certified Solutions Architect - bit.ly/2JrGoAF
    Modern React with Redux - bit.ly/2H6wDtA
    MySQL - bit.ly/2qcF63Z
    ---------------------Follow--------------------------------------------
    My Website - www.codebind.com
    My Blog - goo.gl/Nd2pFn
    My Facebook Page - goo.gl/eLp2cQ
    Google+ - goo.gl/lvC5FX
    Twitter - / programmingknow
    Pinterest - goo.gl/kCInUp
    Text Case Converter - goo.gl/pVpcwL
    ------------------------Stuff I use to make videos ------------------
    Stuff I use to make videos
    Windows notebook - amzn.to/2zcXPyF
    Apple MacBook Pro - amzn.to/2BTJBZ7
    Ubuntu notebook - amzn.to/2GE4giY
    Desktop - amzn.to/2zct252
    Microphone - amzn.to/2zcYbW1
    notebook mouse - amzn.to/2BVs4Q3
    -----------------Facebook Links ---------------------------------------
    ProgrammingKnowledgeLear...
    AndroidTutorialsForBegin...
    Programmingknowledge
    CppProgrammingLanguage
    JavaTutorialsAndCode
    SQLiteTutorial
    UbuntuLinuxTutorials
    EasyOnlineConverter
    netbeans java tutorial
    How to Advanced search a particular data in java netbeans table
    MySQL and NetBeans Search Button
    Java & MySQL Searching your database NetBeans
    Retrieving database records using netbeans
    iit Learn java netbeans
    java tutorial netbeans
    How to search a particular data in java netbeans table
    netbeans search data from database

Komentáře • 35

  • @emiecellibunao4791
    @emiecellibunao4791 Před 11 lety +1

    i think its better to use combobox for specific search then a search button.
    Like this put this to search button or the releasekey in the video
    if(combo.getSelectedItem().equals("ID")){
    String sql="Select * FROM tbl_students where ID=?";
    -
    -
    -
    -
    }
    else if(combo.getSelectedItem().equals("LAST NAME")){
    String sql="Select * FROM tbl_students where LastName=?";
    -
    -
    -
    -
    }
    i wish this come in handy.

  • @duus001
    @duus001 Před 11 lety

    Yes. That would also work. Just remember to add:
    pst.setString(2, txt_search.getText());
    pst.setString(3, txt_search.getText());

  • @cyn0suretarun
    @cyn0suretarun Před 12 lety +2

    what happen when there are two two person with the same name or two person with same surname. I hope you understand my question...

  • @ChaminNalinda
    @ChaminNalinda Před 12 lety +1

    yes sir , we would be glad if you could give a solution for this problem, my problem is that what if there are multiple people with same name and we don't no their emloyeeid(unique id ) either .
    Thank you.

  • @teobais
    @teobais Před 11 lety

    duus001 is right.Suppose the query below :
    select * from EmployeeInfo where name = ? OR surname = ? OR employeeID = ?
    Thus, our prepared Statement has to define 3 different parameters to search apparently in our database.
    So, the only solution is to separate seach field's content into 3 distinct values;tto do this, pass 3 distinct parameters into pst:
    pst.setString(1, searchJTextField.getText());
    pst.setString(2, searchJTextField.getText());
    pst.setString(3, searchJTextField.getText());

  • @dutchman121
    @dutchman121 Před 8 lety +5

    how to show the search result in Table

  • @ikhwansaputera80
    @ikhwansaputera80 Před 9 lety

    Hi, I am very happy to see you about java tutorial video, I want to ask is how to find data on Form1 when in enter will appear form2 to find the data and returns the search results to Form1 back, thank you for, quest, and if it could vedio toturialnya

  • @mukeshsuthar8378
    @mukeshsuthar8378 Před 7 lety +2

    what if user have many entry with same name?

  • @khaledsale7
    @khaledsale7 Před 9 lety +7

    just you can do this :
    try {
    String tmp = search.getText();
    String sql = "select * from Employeeinfo where name=? or employeeid=?" ;
    pst = con.prepareStatement(sql);
    pst.setString(1, tmp);
    pst.setString(2, tmp);
    rs = pst.executeQuery();
    .
    ..
    .
    .
    .
    }

  • @trisetyadarmawan902
    @trisetyadarmawan902 Před 9 lety +1

    thanks :)

  • @IndraRachman
    @IndraRachman Před 11 lety

    just replace if with while in the code that you use to search name and surname

  • @asifhalde6485
    @asifhalde6485 Před 11 lety

    how you took that button group for those buttons ???
    please reply..

  • @lestonyearwood3160
    @lestonyearwood3160 Před 11 lety

    Is there no shorter way to do this? like instead of:
    "select * from Employeeinfo where name =?"
    There could be:
    "select * from Employeeinfo where name =? or employeeid =? or surname =?"

  • @XiiaoBenZaii
    @XiiaoBenZaii Před 11 lety

    Is there any search using keyword??? Like I type in "pa" instand of "paul" and every record start with "pa" will list in JTabel and let user to select which record they want

  • @waqarjamali
    @waqarjamali Před 7 lety

    st=con.prepareStatement("SELECT * FROM EmployeeInfo where Name=? or EmployeeID=? or Surname=? ");
    st.setString(1, search.getText());
    st.setString(2, search.getText());
    st.setString(3, search.getText());

    rs= st.executeQuery();
    this ie enough

  • @qannoufoualid
    @qannoufoualid Před 11 lety

    & what if we have 2 or more similar data ?

  • @advancetechnology760
    @advancetechnology760 Před 6 lety

    How search data record in text field from directly below make a jtable1with already take data from database am dawood pls sir make tutrl

  • @srikirank9846
    @srikirank9846 Před 7 lety

    how to add autocomplete while searching.

  • @Gajenzask
    @Gajenzask Před 9 lety

    How to put the searched data to jtable? Help please

    • @therealslinky62
      @therealslinky62 Před 8 lety +1

      +Tonberry I changed the KeyReleased method on a jTextFeild to filter the table for name only. I added this as a separate jTextFeild called txt_filter as it works differently to the search. It works more like the update_table method. Code is...
      try{
      String sql = "SELECT * FROM Employeeinfo WHERE name LIKE '" + txt_filter.getText() + "%'";
      pst = conn.prepareStatement(sql);
      rs = pst.executeQuery();
      Table_Employee.setModel(DbUtils.resultSetToTableModel(rs));
      }
      catch(Exception e){
      JOptionPane.showMessageDialog(null, e);
      }
      Hope this helps.

  • @javazaljava5978
    @javazaljava5978 Před 10 lety

    Hello .. im new in java. can you please make this program using gui? i cant understand this prog. coz its netbeans i dont know how to use netbeans. i want this prog in gui. please .. help me

  • @andreyv7402
    @andreyv7402 Před 9 lety +1

    Bad practice, why cloning code, what about 'OR' using in the query?

  • @HassanShahzadAheer
    @HassanShahzadAheer Před 11 lety

    what is pst

  • @meljane_abogar
    @meljane_abogar Před 11 lety

    what is the source code of this program??

  • @denzpatricio4749
    @denzpatricio4749 Před 8 lety

    what is pst? i seem to have problem with it. it doesnt recognize when i type it and gives error

  • @dutchman121
    @dutchman121 Před 8 lety +1

    how to show the search result in Table

    • @therealslinky62
      @therealslinky62 Před 8 lety

      +dutch man Hi, Did you find an answer to this? please share if you did. Thanks.

    • @therealslinky62
      @therealslinky62 Před 8 lety

      +dutch man I changed the KeyReleased method on a jTextFeild to filter the table for name only. I added this as a separate jTextFeild called txt_filter as it works differently to the search. It works more like the update_table method. Code is...
      try{
      String sql = "SELECT * FROM Employeeinfo WHERE name LIKE '" + txt_filter.getText() + "%'";
      pst = conn.prepareStatement(sql);
      rs = pst.executeQuery();
      Table_Employee.setModel(DbUtils.resultSetToTableModel(rs));
      }
      catch(Exception e){
      JOptionPane.showMessageDialog(null, e);
      }
      Hope this helps.

    • @mikael2135
      @mikael2135 Před 8 lety

      +therealslinky62 i dont understand about (DbUtils.resultSetToTableModel(rs)), can you explain to me ?
      i used xampp mysql

    • @therealslinky62
      @therealslinky62 Před 8 lety

      +mikael 21 As I undersatand it DButils is a set of classes that help display the database table into the jTable. This is the command that shows the filtered results (rs) onto the jTable. Not best explanation but a google search will help you as well.