1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| DefaultTableModel model = (DefaultTableModel) table_avancement.getModel();
model.setRowCount(0);
table_avancement.setShowGrid(true);
Connection cnx=null;
ResultSet rs=null;
Statement st=null;
try{
Class.forName("com.mysql.jdbc.Driver");
String url="jdbc:mysql://localhost:3306/gestion_personnel";
cnx=DriverManager.getConnection(url,"root","root");
st= cnx.createStatement();
String reqlecture="select * from avancement where pers_matricule='"+f_matricule.getText()+"' order by avan_id desc";
rs= st.executeQuery(reqlecture);
int i=0;
while(rs.next())
{
table_avancement.setValueAt(rs.getString("avan_id"), i, 0);
table_avancement.setValueAt(rs.getString("pers_matricule"), i, 1);
table_avancement.setValueAt(rs.getString("nouvelle_echelon"), i, 2);
table_avancement.setValueAt(rs.getString("date_prise_effet"), i, 3);
i++;
}
} catch(ClassNotFoundException e){
System.err.println(e.getMessage());
} catch(SQLException x)
{
System.err.println(x.getMessage());
} finally{
if(st!= null){
try{
st.close();
} catch(SQLException e1){
e1.printStackTrace();
}
if(rs!= null){
try{
rs.close();
} catch(SQLException e1){
e1.printStackTrace();
}
if(cnx!=null){
try{
cnx.close();
} catch(SQLException e2){
e2.printStackTrace();
}
}
}
}
} |
Partager