I have a table that gets information from my local MySQL server. It reads the data very well and post it on GUI.
My question is , how can I refresh my table when I change my table command, for example:
private String sql = "select * from profildb.tbl_detailed"; //to
private String sql = "select * from profildb.tbl_detailed where Y.."; //this
This action will be handled in my Button Action Listener ;
JButton btnOK = new JButton("");
btnOK.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
if( (tfBirinci.getText().isEmpty() || tfBirinci.getText() == null) && (tfIkinci.getText().isEmpty() || tfIkinci.getText() == null ))
{
taLog.setText("Database alani bos birakilamaz...\n");
}
else if ( (!(tfBirinci.getText().isEmpty() )) && (tfIkinci.getText().isEmpty() || tfIkinci.getText() == null ) )
{
sql = ("SELECT * FROM " + tfBirinci.getText());
taLog.setText("Komut elde edildi : " + sql + "\n");
System.out.println("aaaa " + tfBirinci.getText());
//anaFrame.dispose();
//databaseHistoryCalistir(); doesnt work
}
else if ( ( !(tfBirinci.getText().isEmpty() ) && !(tfBirinci.getText() == null) ) && ( !(tfIkinci.getText().isEmpty() ) && !(tfBirinci.getText() == null) ) )
{
sql = ("SELECT * FROM " + tfBirinci.getText() + " WHERE " + tfIkinci.getText());
taLog.setText("Komut elde edildi : " + sql + "\n" );
System.out.println("bbbb " + tfBirinci.getText());
//anaFrame.dispose();
//databaseHistoryCalistir(); doesnt work
}else
taLog.setText("Lütfen Database alanini doldurunuz, aksi taktirde komut elde edilemez...\n");
}
});
So , what I need to implement for ONLY update the table when I change the statement of my string ?
Thanks in advance. (It would be awesome to give an example about DefaultTableModel)
Edit , You can see my full code here : http://pastebin.com/eQCJVuKn