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
| private void EnregistrerClient() {
PreparedStatement statement;
Connection conn=null;
try {
Class.forName("org.postgresql.Driver");
System.out.println("DRIVER OK ! ");
String url = "jdbc:postgresql://localhost:5433/tabclient";
String user = "postgres";
String passwd = "anissa39";
Connection conn1 = DriverManager.getConnection(url, user, passwd);
String requete= "INSERT INTO tebclients (ID,NOM,PRENOM,ADRESSE,TELEPHONE) VALUES (?,?,?,?,?)";
statement=conn.prepareStatement(requete);
statement.setString(1,saisieIdclient.getText());
statement.setString(2,saisieNom.getText());
statement.setString(3,saisiePrenom.getText());
statement.setString(4,saisieAdresse.getText());
statement.setString(5,saisieTelephone.getText());
statement.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} |