How to auto refresh jComboBox data after update?
<p>I have a <code>jComboBox</code> that getting data from MySQL server database. </p>

<p>When I add new data to database, the <code>jComboBox</code> doesn't show it, and I must reopen my program to add the new data to <code>jComboBox</code>.</p>

<p>How can I refresh <code>jComboBox</code> data automatically?</p>

<p>This is my code :</p>

<pre><code>private void dataComboBox(){
    try {
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/shop","root","");
        Statement stat = con.createStatement();
        String sql = "select id from perfume order by id asc";      
        ResultSet res = stat.executeQuery(sql);                             
        while(res.next()){
            Object[] ob = new Object[3];
            ob[0] = res.getString(1);
            jComboBox5.addItem(ob[0]);                                     
        }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, e);
    }
}


private void showCBdata(){
    try {
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/shop","root","");
        Statement stat = con.createStatement();
        String sql = "select name from perfume where id='"+jComboBox5.getSelectedItem()+"'";  
        ResultSet res = stat.executeQuery(sql);

    while(res.next()){
        Object[] ob = new Object[3];
        ob[0]=  res.getString(1);            
        jTextField8.setText((String) ob[0]);
    }
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, e);
    }
}


//call method
private void jComboBox5ActionPerformed(java.awt.event.ActionEvent evt) {                                           
    showCBdata();
}
</code></pre>

<p>can you help me? </p>

<p>thank you..</p>