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
|
public List interrogation()
{
if (Resultat==null)
{
Resultat=new arrayList();
try{
Class.forname("Classe de ton driver pour mysql");
Connection con=DriverManager.getConnection("ta chaine de connection mysql");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("Select * from personne");
while (rs.next())
{
Personne personne=new personne(rs.getString("Nom"),rs.getInt("Age"),rs.getString("Adresse"));//l'ordre est important
Resultat.add(personne);
}
con.close();//fermer la connection
}
catch(SqlException sqle){//traitement}
catch(ClassNotfoundException cnfe){//traitement}
}
return Resultat;
} |
Partager