lundi 30 novembre 2015

i want to show id column from database in jcombobox please help me as soon as possible

jcombobox keep repeating result every time whenever i select item, i want to show id column from database in jcombobox please help me as soon as possible studentidd is variable of jcombobox

http://ift.tt/1Q92oyN

private void studentiddActionPerformed(java.awt.event.ActionEvent evt) {                                           
      // it working but results keep repeating same row again an again          

        try { 
             Class.forName("org.sqlite.JDBC");

        Connection conn =(Connection) DriverManager.getConnection("jdbc:sqlite:studentdb.sqlite");
        Statement stat = conn.createStatement();
        ResultSet rs;
        rs = stat.executeQuery("SELECT id from student_table");

             while (rs.next())
             {      
              String name = rs.getString("id");         
              studentidd.addItem(rs.getString("id"));

             }//end while
             rs.close();
             } catch (Exception e) {
                  e.printStackTrace();
             }
    }

Aucun commentaire:

Enregistrer un commentaire