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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
| Object s=j.getItem(); //j nom de mon JComboBox
String A=s.toString();
String tab[]=A.split(" "); //les item sont de forme "nom prenom"
String b=tab[0];
String h=tab[1];
DossierPatient d=new DossierPatient();
String query1= "SELECT * FROM patient "+" WHERE nom='"+b+"' AND prenom='"+h+"';";
String UrlBase = "jdbc:postgresql://localhost/*********";
String driver="org.postgresql.Driver";
String user = "postgres";
String MDP="****";
try {
Class.forName("org.postgresql.Driver");
} catch (ClassNotFoundException ex) {
Logger.getLogger(box.class.getName()).log(Level.SEVERE, null, ex);
}
Connection conn = null;
try {
conn = DriverManager.getConnection(UrlBase, user, MDP);
} catch (SQLException ex) {
Logger.getLogger(box.class.getName()).log(Level.SEVERE, null, ex);
}
Statement state = null;
try {
state = conn.createStatement();
} catch (SQLException ex) {
Logger.getLogger(box.class.getName()).log(Level.SEVERE, null, ex);
}
ResultSet result1 = null;
try {
result1 = state.executeQuery(query1 );
} catch (SQLException ex) {
Logger.getLogger(box.class.getName()).log(Level.SEVERE, null, ex);
}
try {
while( result1.next()){
String nom= result1.getString("nom");
String prénom= result1.getString("prenom");
String sexe= result1.getString("sexe");
String lieu= result1.getString("lieuNaissance");
String date= result1.getString("dateNaissance");
String act= result1.getString("activité");
String adr= result1.getString("adresse");
String num= result1.getString("numeroTel");
String pie= result1.getString("pieceJointe");
String code= result1.getString("codePatient");
d.c.setText(code);
d.nom.setText(nom);
d.date.setText(date);
d.num.setText(num);
d.pièce.setText(pie);
d.lieu.setText(lieu);
d.sexe.setText(sexe);
d.activité.setText(act);
d.prenom.setText(prénom);
d.adresse.setText(adr);
}
} catch (SQLException ex) {
Logger.getLogger(box.class.getName()).log(Level.SEVERE, null, ex);
}
} |
Partager