slt tout le monde j'ai un probleme avec mon programe java quan j'excecute voicie le message qu'il me donne;
Erreur SQL:java.sql.SQLException:[Microsoft][PILOTE ODBC Microsoft Access]
le nombre de valeur de la requete doit concider avec le nombre de chanmps destination.
voicie mon code java:
public class Produit {
private String codePrd;
private String desig;
private int QteStock;
// private Concerne concerne;
// private Constitue constitue;
// private Contenire contenire;
private String Base;
public String getcodePrd(){
return codePrd;
}
public String getdesig(){
return desig;
}
public int getQteStock(){
return QteStock;
}
public void setcodePrd(String codePrd){
this.codePrd = codePrd;
}
public void setdesig(String desig){
this.desig = desig;
}
public void setQteStock(int QteStock){
this.QteStock = QteStock;
}
public Produit(String Base){
this.Base = Base;
}
public Produit(String codePrd,String desig,int QteStock,String Base){
setcodePrd(codePrd);
setdesig (desig);
setQteStock(QteStock);
this.Base = Base;
}
public void ajouter(){
SQLProduit unSQLProduit = new SQLProduit( codePrd, desig, QteStock,Base);
unSQLProduit.ajouter();
}
public void consulter(){
SQLProduit unSQLProduit = new SQLProduit( codePrd, desig, QteStock,Base);
}
//public void modifier(){
//SQLProduit unSQLProduit = new SQLProduit( codePrd, desig, QteStock,Base);
//unSQLProduit.modifier();
//}
//public void supprimer(){
//SQLProduit unSQLProduit = new SQLProduit( codePrd, desig, QteStock,Base);
//unSQLProduit.supprimer();
//}
}
///SQL PRODUIT
import java.sql.*;
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;
import java.lang.*;
/**
*
* @author mawezo
*/
public class SQLProduit {
private String codePrd;
private String Base;
private String desig;
private int QteStock;
// private Concerne concerne;
// private Constitue constitue;
//private Contenire contenire;
public String getcodePrd(){
return codePrd;
}
public String getdesig(){
return desig;
}
public int getQteStock(){
return QteStock;
}
public void setcodePrd(String codePrd){
this.codePrd = codePrd;
}
public void setdesig(String desig){
this.desig = desig;
}
public void setQteStock(int QteStock){
this.QteStock = QteStock;
}
/** Creates a new instance of SQLproduit */
public SQLProduit (String Base){
this.Base = Base;
}
public SQLProduit(String codePrd,String desig,int QteStock,String Base){
setcodePrd(codePrd);
setdesig(desig);
setQteStock(QteStock);
this.Base = Base;
}
public void ajouter(){
ConnexionBase uneConnexionBase = new ConnexionBase(Base);
Connection con = uneConnexionBase.getConnection();
try {
PreparedStatement pst = con.prepareStatement("insert into Produit(codePrd,desig,QteStock) values (?,?,?,now())");
pst.setString(1,getcodePrd());
pst.setString(2,getdesig());
pst.setInt(3,getQteStock());
int nbr = pst.executeUpdate();
pst.close();
con.close();
}
catch(SQLException sqle){ System.err.print("Erreur SQL :" + sqle ); }
catch (Exception e) { System.err.print("Erreur :" + e ); }
}
}
import java.sql.*;
public class ConnexionBase {
private String Base;
private Connection connection ;
public ConnexionBase(String Base){
this.Base = Base ;
}
public void setBase(String Base) {
this.Base = Base ;
}
public void setConnection(Connection con) {
this.connection = connection ;
}
/**
* Renvoie l'objet Connexion
*/
public String getBase() {
return Base ;
}
public Connection getConnection(){
Connection con=null;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection ("jdbc:odbc:"+Base);
}
catch(Exception sql) {
String exp="Class ConnectionBase\n"+
"method getConnection()\n"+
"exception : "+sql.getMessage();
javax.swing.JOptionPane.showMessageDialog(null,sql,"Exception au niveau de connection Base", javax.swing.JOptionPane.ERROR_MESSAGE);
}
return con;
}
}
import javax.swing.*;
import java.lang.*;
public class FormulaireProduit extends javax.swing.JFrame {
String Base="djo";
String Contexte = "Ajout";
//RechercherProduit FenMere;
public FormulaireProduit(){ initComponents();}
public FormulaireProduit(String Contexte,Produit unProduit) {
this.Contexte = Contexte;
// this.FenMere = fen;
initComponents();
try {
UIManager.setLookAndFeel("org.fife.plaf.OfficeXP.OfficeXPLookAndFeel");
SwingUtilities.updateComponentTreeUI(this);
}
catch (Exception e) {
System.err.println("Oops! Something went wrong!");
}
}
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
ch_codePrd = new javax.swing.JTextField();
ch_desig = new javax.swing.JTextField();
ch_QteStock = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jLabel4 = new javax.swing.JLabel();
getContentPane().setLayout(null);
jLabel1.setText("Code Produit");
getContentPane().add(jLabel1);
jLabel1.setBounds(50, 100, 130, 14);
jLabel2.setText("Designation");
getContentPane().add(jLabel2);
jLabel2.setBounds(50, 170, 90, 14);
jLabel3.setText("Quantit\u00e9 Stock");
getContentPane().add(jLabel3);
jLabel3.setBounds(50, 250, 90, 14);
getContentPane().add(ch_codePrd);
ch_codePrd.setBounds(200, 100, 130, 20);
getContentPane().add(ch_desig);
ch_desig.setBounds(200, 160, 130, 19);
getContentPane().add(ch_QteStock);
ch_QteStock.setBounds(200, 250, 130, 19);
jButton1.setText("Ajout");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
getContentPane().add(jButton1);
jButton1.setBounds(70, 320, 90, 23);
jButton2.setText("Annule");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
getContentPane().add(jButton2);
jButton2.setBounds(200, 320, 140, 23);
jLabel4.setFont(new java.awt.Font("Arial", 1, 14));
jLabel4.setText("Formulaire Produit");
getContentPane().add(jLabel4);
jLabel4.setBounds(60, 30, 300, 40);
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setBounds((screenSize.width-506)/2, (screenSize.height-433)/2, 506, 433);
}
// </editor-fold>//GEN-END:initComponents
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
// TODO add your handling code here:
this.dispose();
}//GEN-LAST:event_jButton2ActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
//if (Contexte.equals("Consultation")){
// this.setVisible(false);
//this.dispose();
//};
if (Contexte.equals("Ajout")) {
Produit unProduit = new Produit(Base);
unProduit.setcodePrd(ch_codePrd.getText());
unProduit.setdesig(ch_desig.getText());
int qt = Integer.parseInt(ch_QteStock.getText());
unProduit.setQteStock(qt);
unProduit.ajouter();
ch_codePrd.setText("");
ch_desig.setText("");
ch_QteStock.setText("");
}
}//GEN-LAST:event_jButton1ActionPerformed
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
FormulaireProduit unFormulaireProduit = new FormulaireProduit();
unFormulaireProduit.setVisible(true);
// unFormulaireProduit.pack();
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextField ch_QteStock;
private javax.swing.JTextField ch_codePrd;
private javax.swing.JTextField ch_desig;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
// End of variables declaration//GEN-END:variables
}
VOILA TOUT MON CODE SOURCE ET j'ai besouin d'aide
pas de signature