Ajouter a la base de donnée
Résolu/Fermé
djatou abdelkrim
-
KX Messages postés 16761 Date d'inscription Statut Modérateur Dernière intervention -
KX Messages postés 16761 Date d'inscription Statut Modérateur Dernière intervention -
Bonjour,
public static void main(String[] args) throws ClassNotFoundException, SQLException {
// TODO code application logic here
Class.forName("com.mysql.jdbc.Driver");
System.out.println("Driver reussi");
Connection cn= DriverManager.getConnection("jdbc:mysql://localhost/bb_sco","root","dja");
System.out.println("Conexion reussi");
Statement st=cn.createStatement();
int nbr=st.executeUpdate("insert dja values('ahamde','kadour','23')");
System.out.println(nbr);
}
il afficher
run:
Driver reussi
Conexion reussi
Exception in thread "main" java.sql.SQLException: Column count doesn't match value count at row 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1056)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3376)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3308)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1837)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1961)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2537)
at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1564)
at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1485)
at conxi.Conxi.main(Conxi.java:30)
Java Result: 1
Cherchez l'erreur
public static void main(String[] args) throws ClassNotFoundException, SQLException {
// TODO code application logic here
Class.forName("com.mysql.jdbc.Driver");
System.out.println("Driver reussi");
Connection cn= DriverManager.getConnection("jdbc:mysql://localhost/bb_sco","root","dja");
System.out.println("Conexion reussi");
Statement st=cn.createStatement();
int nbr=st.executeUpdate("insert dja values('ahamde','kadour','23')");
System.out.println(nbr);
}
il afficher
run:
Driver reussi
Conexion reussi
Exception in thread "main" java.sql.SQLException: Column count doesn't match value count at row 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1056)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3376)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3308)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1837)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1961)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2537)
at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1564)
at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1485)
at conxi.Conxi.main(Conxi.java:30)
Java Result: 1
Cherchez l'erreur
A voir également:
- Ajouter a la base de donnée
- Base de registre - Guide
- Ajouter à l'écran d'accueil iphone - Guide
- Formules mathématiques de base - Télécharger - Études & Formations
- Ajouter signature word - Guide
- Ajouter liste déroulante excel - Guide