Mysql
 sql >> Database >  >> RDS >> Mysql

ListArray Salvataggio Stessi record

Students tempStudent = new Students(); 

cambialo in

Students tempStudent;

Stai overridding la property of same object poiché hai creato il tempStudent outside il while loop . Devi aggiungere gli objects uguale al number of record nella banca dati. Quindi crea l'tempStudent object come di seguito.

usa

while (rs.next()) {
        tempStudent = new Students();
        tempStudent.studentId = rs.getInt("StudentNo");
        tempStudent.studentName = rs.getString("StudentName");
        tempStudent.studentAge = rs.getInt("StudentAge");
        students.add(tempStudent);
        size++;
    }