Add Items in JComboBox in java swing
try
{
Class.forName("com.mysql.jdbc.Driver");
java.sql.Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3305/rms","root","root");
String sql="select name from categories";
java.sql.PreparedStatement pst=con.prepareStatement(sql);
ResultSet rs = pst.executeQuery(sql);
while(rs.next())
{
String name=rs.getString(1);
jComboBox1.addItem(name);
}
con.close();
pst.close();
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null, e);
}