I have two comboboxes ... First one shows the cities of hotels and the second one shows tha hotels name based on the city selected in first combo box. First Combobox is working correctly. second one shows is only for the first selected city. it does not make changes to itself after changing the city in first combo box ! what do I have to add to this code in order to be able to see changes in second combobox by changing the first combobox.
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/JEREN","root","");
Statement stat = con.createStatement();
String City_Selected = jComboBox1.getSelectedItem().toString();
String select_HN = "select name from tbl_Hotel where city = '"+City_Selected+"';";
ResultSet rs = stat.executeQuery(select_HN);
while (rs.next())
{
String hotel_name = rs.getString("name");
// jLabel3.setText(hotel_name);
jComboBox2.addItem(hotel_name);
}//end while
rs.close();
stat.close();
con.close();
} catch (Exception e) {
e.printStackTrace();
}