troubleshooting Question

Auto-Refresh JTable in Netbeans IDE

Avatar of octoberqueen
octoberqueenFlag for India asked on
Java
5 Comments1 Solution7474 ViewsLast Modified:

Screenshot of my project window:

mayajaal-mainwindow
When the user clicks 'ADD RECORDS' button, this dialog will appear

mayajaal-addwindow

Code for 'ADD RECORDS' Button

     private void addBtnActionPerformed(java.awt.event.ActionEvent evt) {                                       
String movie = movTF.getText();
String screen = screenTF.getText();
String showTime = stTF.getText();
String endTime = etTF.getText();
    
 if (movie.equals(""))
    JOptionPane.showMessageDialog(this,"Movie Not Entered");
  
else if(screen.equals(""))
    JOptionPane.showMessageDialog(this,"Language Not Entered");

else if(showTime.equals(""))
    JOptionPane.showMessageDialog(this,"ShowTime Not Entered");

   
   

else{

try
{
    
        
Class.forName("java.sql.DriverManager");

Connection con = (Connection)
        
DriverManager.getConnection ("jdbc:mysql://localhost:3306/cbse","root", "tiger");

Statement stmt = (Statement) con.createStatement();

String query="INSERT INTO singlemayajaal VALUES ('"+showTime+"','"+endTime+"','"+screen+"','"+movie+"');";
stmt.executeUpdate(query);

JOptionPane.showMessageDialog (this,"Movie Added Successfully");  




movTF.setText("");
screenTF.setText("");
stTF.setText("");
etTF.setText("");

    
    }


catch(Exception e)

{
JOptionPane.showMessageDialog (null,"Something is Wrong.Please check whether all fields are filled properly");
}
      
    }                                      

    
    }   
   

MySQL Database Name: cbse
MySQL Table Name      : singlemayajaal



Now this is my question:

If I enter values in ADD Dialog and press OK, like:

 mayajaal-sample-add-values-added.png

The Movie JTable should be automatically updated with the new values, like:

  mayajaal-sample-add-values-jtabl
The Mysql Databse table should be also updated with new info.


How can I do it? I don't have much knowledge or grasp in Netbeans and Java.

I need a step-by-step help.

ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros