Probleme ajout a une base de donnee
Résolu
xdev10
Messages postés
8
Date d'inscription
Statut
Membre
Dernière intervention
-
xdev10 Messages postés 8 Date d'inscription Statut Membre Dernière intervention -
xdev10 Messages postés 8 Date d'inscription Statut Membre Dernière intervention -
Bonsoir , apres execution de ce code il y a eu un declenchement d'une execption
package rrr;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
public class AjoutTable {
public static void main(String[] args) {
try{
Class.forName("org.postgresql.Driver");
System.out.println("Driver O.K.");
String url = "jdbc:postgresql://localhost/ClubVideo";
String user = "postgres";
String passwd = "projet";
Connection conn = DriverManager.getConnection(url, user, passwd);
System.out.println("Connexion effective !");
PreparedStatement state = conn.prepareStatement("INSERT INTO realisateur (id realisateur,nom,prenom) VALUES(12,'SALMON', 'Dylan')");
state.executeUpdate("INSERT INTO realisateur (id realisateur,nom,prenom) VALUES(12,'SALMON', 'Dylan')");
//afficheTable p = new afficheTable();
conn.close();
}
catch(Exception e)
{
System.out.println("erreur insertion");
}
}
}
A voir également:
- Probleme ajout a une base de donnee
- Base de registre - Guide
- La base de données de sécurité du serveur n'a pas de compte d'ordinateur pour la relation ✓ - Forum Réseau
- Ajout rapide snap - Forum Snapchat
- Ajout rapide snap - Forum Snapchat
- Formules mathématiques de base - Télécharger - Études & Formations
3 réponses
Bonjour,
Pour savoir quelle exception est levée il faudrait l'afficher.
Pour savoir quelle exception est levée il faudrait l'afficher.
catch (Exception e) { e.printStackTrace(); }
il m'a affiche cette exception
ERREUR: erreur de syntaxe sur ou près de « realisateur »
Position : 28
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2182)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1911)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:173)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:645)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:481)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:409)
at rrr.AjoutTable.main(AjoutTable.java:26)