title: JCombobox value retrieve from MySql Data base
body: <p>I use the following code for retrieve the data from my Sql DB.retrieve StudName and StudId from Data Base.StudName will display JComboBox.But how to show the StudId in Messagebox.If I select the first record in combo box means i need the corresponding Id in Message box.how to do this?
   thanks in Advance</p>
  
  <pre><code>public class FrmeA extends javax.swing.JFrame  {
  
            FrmA1 f1=new FrmA1();
            Statement TmpFlxTSt=null;
            ResultSet TmpFlxTRs=null;
            GContnStr GCS=new GContnStr();
  
          public FrmeA() {
               initComponents();
          }
      public void combo(){
  
           try{
                      GCS.GContnStr();
                      TmpFlxTSt= GCS.GCotnStr.createStatement();
                      String select = "Select StudId,StudName from studentmaster";
                      TmpFlxTRs = TmpFlxTSt.executeQuery(select);
                        while(TmpFlxTRs.next()){
                         cbx.addItem(TmpFlxTRs.getString("StudName"));
                         Object comboitem=cbx.getSelectedItem();
  
                     }
                          TmpFlxTRs.close();
                          TmpFlxTSt.close();
              }
                 catch(Exception e){
                     System.out.println(e);
  
          }
  
      }
  </code></pre>