I want to add employee name from database to combobox
and i am using the coding


but the combobox appears consisting elements as Item1,Item2,Item3...and so on
how I can add employees names in combobox

hai Sweksha,

i think you are using netbeans IDE to develop the appilication.so that those values are coming by default with JCombobox.

for this , you have to call removeAllItems() avialable in the JCombobox class before inserting data into combobox

i mean calll the following statement before while loop

// your remaining code goes here

thats it

let me know the status ......

happy coding

Try this:
(combobox1 is the variable name of the combobox you are using to display the emp_name

 public void fillCombo() {
        Connection con = null;
        ResultSet rs = null;
        java.sql.PreparedStatement st = null;
        Properties conProps = new Properties();
        conProps.setProperty("user", "root");
        conProps.setProperty("password", "root");

        try {
            con = DriverManager.getConnection("jdbc:mysql://localhost:3306/dbName", conProps);
            String sql = ("select * from TbName");

            while (rs.next()) {
                String y = rs.getString("emp_name");



        } catch (Exception e) {