我想用数据库Nilai用数据库mapel和textfield更改我的Label。我已经尝试了很多方法,但它不起作用。你们有什么想法吗?
try{
sql2 = "SELECT Mapel, Nilai FROM Nilai where NIM = '" + tf_main.getText() + "'";
rs3 = stmt.executeQuery(sql2);
while(rs3.next()){
siswa asd = new siswa();
String nilai = rs3.getString("Nilai");
asd.label_nilai1.setText(rs3.getString("Mapel"));
asd.tf_nilai1.setText(nilai);
}
}
}catch(SQLException se){
se.printStackTrace();
}catch(Exception aae){
aae.printStackTrace();
}
label_nilai1 = new JLabel(MP1);
label_nilai2 = new JLabel(MP2);
label_nilai3 = new JLabel(MP3);
label_nilai4 = new JLabel(MP4);
label_nilai5 = new JLabel(MP5);
tf_nilai1 = new JTextField(15);
tf_nilai2 = new JTextField(15);
tf_nilai3 = new JTextField(15);
tf_nilai4 = new JTextField(15);
tf_nilai5 = new JTextField(15);