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
|
public class Main {
/**
* @param args
* @throws ClassNotFoundException
* @throws SQLException
*/
public static void main(String[] args) throws ClassNotFoundException, SQLException {
// TODO Auto-generated method stub
String pilote = "com.mysql.jdbc.Driver";
try {
Class.forName(pilote);
Connection connexion = DriverManager.getConnection("jdbc:mysql://dev1srv/recrutement","login","mdps");
Statement instruction = connexion.createStatement();
ResultSet resultat = instruction.executeQuery("SELECT * FROM tbl_candidats");
while(resultat.next()){
System.out.println("---------------------------");
System.out.println("N° ID_CANDIDAT: "+resultat.getInt("ID_CANDIDAT"));
System.out.println("Nom: "+resultat.getString("NOM"));
System.out.println("Prénom: "+resultat.getString("PRENOM"));
}
instruction.close();
resultat.close();
} catch (Exception e) {
// TODO: handle exception
System.out.println("echec pilote : "+e);
}
}
} |
Partager