Suppression d'une ligne d'une table de BDD (pgadmin) à partir de Java
Salut ;
Je cherche l'instruction sur java qui fait la suppression d'une ligne de ma table dans ma BDD pgadmin
Voila mon code j'ai tout mets dans une fonction après faire l'appel a cette méthode avec le bouton supprimer pour supprimer une ligne
Code:
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 void connection_delete() throws ClassNotFoundException
{
try {
Class.forName("org.postgresql.Driver");
String url = "jdbc:postgresql://localhost:5432/sonelgez";
String user = "postgres";
String passwd = "2890khadidja";
Connection conn = DriverManager.getConnection(url, user, passwd);
System.out.println("connection ok !");
//Création d'un objet Statement
Statement state = (Statement) conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
state.executeQuery("DELETE FROM agence WHERE numag=1");
state.close();
} catch (Exception e) {
e.printStackTrace();
}
} |
l'erreur est ici
Citation:
state.executeQuery("DELETE FROM agence WHERE numag=1");