faloujien
Messages postés3Date d'inscriptionlundi 13 novembre 2006StatutMembreDernière intervention22 décembre 2008
-
20 déc. 2008 à 08:56
Bruno -
25 avril 2019 à 14:29
Bonjour a tous,
Je suis débutant en java,je veux realiser une interface permettant d'ajouter des donneés dans une base de bonnées mysql,
J'ai saisis un code mais il affiche des messages d'erreur et g pas pu les resourdes.
Voici le code:
import javax.swing.*;
Chargement du pilote Mysql réussi
java.lang.NullPointerException
at Client.actionPerformed(Client.java:67)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
j'ai besoin d'aide s'il vous plait et je serai reconnaissant.
faloujien
Messages postés3Date d'inscriptionlundi 13 novembre 2006StatutMembreDernière intervention22 décembre 2008 22 déc. 2008 à 09:24
merci moutombo pour ton aide.J'ai changer le nom de la table en minuscule mais les mêmes messages d'erreur s'affichent.
En fait les données vont s'ajouter a la base par click sur un bouton n'est ce pas?
Si tu essaye d'exécuter mon code sur éclipse tu va voir les erreurs.
Je suis débutant en java et je suis bloqué.
faloujien
Messages postés3Date d'inscriptionlundi 13 novembre 2006StatutMembreDernière intervention22 décembre 2008 22 déc. 2008 à 16:58
J'ai pu rectifier un peux le code en ajoutant la ligne suivante:
String QueryString="insert into personne('txt.getString()','txte.getString()')";
stat.executeUpdate(QueryString);
le nobre d'erreur est diminué mais il toujours des erreurs:
les voila:
Chargement du pilote Mysql réussi
SQLException: Erreur de syntaxe près de ''txt.getString()','txte.getString()')' à la ligne 1
SQLState: 42000
VendorError: 1064
JPanel panelbas=new JPanel(new FlowLayout());
titre.setForeground(Color.red);
titre.setFont(new Font("TimesRoman",Font.ITALIC,18));
titre.setText(" ----- FICHE CLIENT -----");
c.add(titre);
//zone de saisie pour le nom l'adresse et le telephone
txtnom=new JTextField();
txtpre=new JTextField();
txtadr=new JTextField();
txttel=new JTextField();
txtfax=new JTextField();
txtlocal=new JTextField();
txtsite=new JTextField();
//Object[] pai= {"Chèque bancaire", "Espèce","Carte bleu", "Chèques"};
//JComboBox txtmoy = new JComboBox(pai);
//ajout des etiquettes et des zones de saisie au panel
panelcentre.add(new JLabel("Nom :",SwingConstants.RIGHT));
panelcentre.add(txtnom);
panelcentre.add(new JLabel("Prénom :",SwingConstants.RIGHT));
panelcentre.add(txtpre);
panelcentre.add(new JLabel("Adresse :",SwingConstants.RIGHT));
panelcentre.add(txtadr);
panelcentre.add(new JLabel("Téléphone :",SwingConstants.RIGHT));
panelcentre.add(txttel);
panelcentre.add(new JLabel("Fax :",SwingConstants.RIGHT));
panelcentre.add(txtfax);
panelcentre.add(new JLabel("Localisation :",SwingConstants.RIGHT));
panelcentre.add(txtlocal);
panelcentre.add(new JLabel("Site Internet :",SwingConstants.RIGHT));
panelcentre.add(txtsite);
//panelcentre.add(new JLabel("MOYEN :",SwingConstants.RIGHT));
//panelcentre.add(txtmoy);
c.add(panelcentre);
//creer et ajoutter des boutons au panel de bas
btnAjout=new JButton("Ajouter");
btnEffacer=new JButton("Effacer");
btnFermer=new JButton("Fermer");
panelbas.add(btnAjout);
panelbas.add(btnEffacer);
panelbas.add(btnFermer);
c.add(panelbas);
//enregistrer le frame comme auditeur de bouton
btnAjout.addActionListener(this);
btnEffacer.addActionListener(this);
btnFermer.addActionListener(this);
this.setSize(400,450);
this.setTitle("AJOUT DE CLIENT");
this.setVisible(true);
//creer une classe anonyme pour gerer la fermeture de la fenetre
this.addWindowListener(new WindowAdapter()
{
public void windoClosing(WindowEvent ev)
{
fermerFormulaire();
}
}
);
}//fin du constructeur
public void actionPerformed(ActionEvent e)
{
//déterminer si on cliqué sur un bouton
if(e.getSource()==btnAjout)
{
ajouterClient();