i want combobox to display 3 different kind of names i.e name,city and gotra
<p>In my project I have one search form in that we have 2 combobox
:in first combobox(cbsearch) I have added three items i.e name,city and gotra and I have taken second combobox(cbdisplay) to display the data.</p>

<p>I want that when I select items from first combobox(anyone  name ,city and gotra)than second combobox should display that all the names.means when I select city in first combobox the second combobox should display all city name present in my DB same for other two items i.e(name,gotra):
I am using netbeans 6.9.1 my code is:(I have write this code in customize code section of second combobox(cbdisplay) help me its displaying only name not city and gotra name)</p>

<pre><code>String searchby= cbsearch.getSelectedItem().toString();
 if(searchby.equals(""))
 JOptionPane.showMessageDialog(null," SELECT ANY ONE EITHER NAME,GOTRA,CITY");
  if(cbsearch.getSelectedItem().toString().equals("Name"))
{
                try                               //1st combobox is cbsearch
        {                                 //2nd combobox is cbdisplay

        cbdisplay.setEditable(true);
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection con=DriverManager.getConnection("jdbc:odbc:wanisamajDB");
        String query="Select Name from FAMILYcensus;";
        Statement st=con.createStatement();
        ResultSet res=st.executeQuery(query);
                String temp;

        while(res.next())
        {

                      temp=res.getString(1);
              cbdisplay.addItem(temp);


        }
                 con.close();
                 st.close();

        }
        catch(Exception e)
        {
            System.out.println("Error");
        }
        finally
        {
             //P1.add(cmb);
            //cbregno.setBounds(175,30,150,20);
                cbdisplay.setSize(150,20);
                    }
        }
 if(cbsearch.getSelectedItem().toString().equals("City"))
{
                try
        {

        cbdisplay.setEditable(true);
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection con=DriverManager.getConnection("jdbc:odbc:wanisamajDB");
        String query="Select LivingArea from FAMILYcensus;";
        Statement st=con.createStatement();
        ResultSet res=st.executeQuery(query);
                String temp;

        while(res.next())
        {

                      temp=res.getString(1);
              cbdisplay.addItem(temp);


        }
                 con.close();
                 st.close();

        }
        catch(Exception e)
        {
            System.out.println("Error");
        }
        finally
        {
             //P1.add(cmb);
            //cbregno.setBounds(175,30,150,20);
                cbdisplay.setSize(150,20);
                    }
        }
 if(cbsearch.getSelectedItem().toString().equals("Gotra"))
{
                try
        {

        cbdisplay.setEditable(true);
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection con=DriverManager.getConnection("jdbc:odbc:wanisamajDB");
        String query="Select Gotra from FAMILYcensus;";
        Statement st=con.createStatement();
        ResultSet res=st.executeQuery(query);
                String temp;

        while(res.next())
        {

                      temp=res.getString(1);
              cbdisplay.addItem(temp);


        }
                 con.close();
                 st.close();

        }
        catch(Exception e)
        {
            System.out.println("Error");
        }
        finally
        {
             //P1.add(cmb);
            //cbregno.setBounds(175,30,150,20);
                cbdisplay.setSize(150,20);
                    }
</code></pre>
