Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8185875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:00:13+00:00 2026-06-07T02:00:13+00:00

I have a table that gets information from my local MySQL server. It reads

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T02:00:15+00:00Added an answer on June 7, 2026 at 2:00 am

    1) use Table from Database by @camickr

    2) use one of ResultsetTableModel

    3) call SQL statement from Runnable#Thread, but output to the XxxTableModel must be inside invokeLater, more in the Concurency in Swing about Event Dispatch Thread (EDT)

    4) call SQL statement from SwingWorker, then output from progress(), publish() or done() should be on EDT

    5) DefaultTableModel doesn’t required override methods fireXxxTableXxx, all of them are correctly implemented

    6) difference betweens logics Table from Database (ResultsetTableModel) and Runnable#Thread(SwingWorker) is

    • Table from Database (ResultsetTableModel) calling all updates on EDT, then GUI waiting for all event are done, during loading data from database is GUI unresponsible or freeze

    • Runnable#Thread(SwingWorker) all updates are from backgourng task and GUI is resposible for Mouse and Keyboard events,

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UITableView that gets information from a server and publishes the data
I have an Excel file that gets external data from database table. I need
I have a MySQL query that: gets data from three tables linked by unique
For example I have a dropdown box that gets a town from the table
I have table that I insert data with following query (from c# code): INSERT
I have a crystal report that gets its data from one stored procedure, this
I have constructed a array that gets the information from checkboxes. This is working
I have multiple buttons that gets created in a table which all look like
I have a self referencing table in Oracle 9i, and a view that gets
I have those code snippet that checks the fans table and gets everyone who

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.