I have problem that when i click JComboBox i will display all ProductName in JComboBox but when i click it again the items becomes dusplicate means again select statement called i only want that if i click once it will update the JComboBox not as many times i click it will update i am using Action on Click This is my Code
Please help me.
try
{
java.lang.Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
java.sql.Connection xcon = java.sql.DriverManager.getConnection("jdbc:odbc:NADEEMSONS","sa","123");
Statement st=xcon.createStatement();
ResultSet result = st.executeQuery("Select PNAME from products_details");
while(result.next())
{
String cmb = result.getString("PNAME");
cmbProduct1.addItem(cmb);
}
}
catch(java.lang.ClassNotFoundException | java.sql.SQLException ex1){}