0
    try{ 

        String b = jTextField1.getText();

     String sql = "SELECT * FROM DataImput ORDER BY InvoiceNumber=?";
     pst=conn.prepareStatement(sql);      
     pst.setString(1, b);

     rs=pst.executeQuery();

     jTable1.setModel(DbUtils.resultSetToTableModel(rs));

    }

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

    } finally{
    try{
       rs.close();
       pst.close();                
    }
        catch(Exception e){        
        }                
    }

    }

this is the code I work to search. it actually work. but really weird. it show the item I want the last one. and show all items in it. how can I make it show only search data?

items = data I've enter inside

2
Contributors
2
Replies
14
Views
2 Years
Discussion Span
Last Post by stultuske
1

your title is "Search is not working", then you say "This is the code I work to search. it actually work."

Either it works, or it doesn't.

"It show the item I want" => isn't that what your code is supposed to do? and how do you mean "the last one"?

can you be more clear? maybe you can give us an idea of the contents of your table, the value of b, the output you want and the output you actually get.

That might make it easier for us to spot the issue.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.