Java project probl
ennaoui-khouloud
Messages postés
3
Date d'inscription
Statut
Membre
Dernière intervention
-
greg6614 Messages postés 629 Statut Membre -
greg6614 Messages postés 629 Statut Membre -
salut , je suis une étudiante informatique je suis encore débutante et c est mon 1er projet en java je travail avec NetBeans mon problème que lors que je remplie le formulaire et je clic sur bouton enregistrer en principe que les données sont enregistrer dans ma base de donnée (j ai deja réalisé ma classe connexion avec ma base de donne )et que les champs seront vides mais tjr il y'a des erreurs ..... mais je sais pas qu est ce que je fais so help me as much as you can please :*

1 réponse
-
Salut, il nous faudrait une stackTrace de tes erreurs histoire de voir où ça coince. Également ton bout de code pourrait nous aider.
-
<gras>voila le code de class connexion :
import java.sql.*;
public class connection {
Connection con;
String urlp="oracle.jdbc.driver.OracleDriver";
String urlb="jdbc:oracle:thin:@localhost:1521:XE";
{ try {
Class.forName(urlp);
System.out.println("pilote chargé");
}
catch( ClassNotFoundException ex ){
System.out.println(ex);
}
}
{
try {
con = (Connection) DriverManager.getConnection(urlb,"SYSTEM","123456");
System.out.println("connexion a la base de donnes");
}
catch (SQLException ex){
System.out.println(ex);
}
}
Connection ObtenirConnexion(){
return con ;
}
}
et pour bouton enregistrer voile le code :
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
String requete_patient= "INSERT INTO PERSONNEL('"+jTextField9.getText()+"','"+jTextField1.getText()+"','"+jDateChooser1.getDate()+"',"+jTextField3.getText()+"',"+
jTextField4.getText()+"','"+jTextField6.getText()+"','"+jTextField10.getText()+"','"+jTextField11.getText()+"','"+jTextField2.getText()+"',)";
try{
stmt= mcon.ObtenirConnexion().createStatement();
stmt.executeQuery(requete_patient);
JOptionPane.showMessageDialog(null, "patient enregistré avec succes");
jTextField9.setText("");
jTextField1.setText("");
jTextField3.setText("");
jTextField4.setText("");
jTextField5.setText("");
jTextField6.setText("");
jTextField10.setText("");
jTextField11.setText("");
jTextField2.setText("");
}
catch (SQLException ex){
System.out.println(ex);
}
} -
-
voila les erreurs affiche :
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@localhost:1521:XE
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at ajoutpersonel.jButton2ActionPerformed(ajoutpersonel.java:366)
at ajoutpersonel.access$200(ajoutpersonel.java:18)
at ajoutpersonel$3.actionPerformed(ajoutpersonel.java:119)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6535)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6300)
at java.awt.Container.processEvent(Container.java:2236)
at java.awt.Component.dispatchEventImpl(Component.java:4891)
at java.awt.Container.dispatchEventImpl(Container.java:2294)
at java.awt.Component.dispatchEvent(Component.java:4713)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
at java.awt.Container.dispatchEventImpl(Container.java:2280)
at java.awt.Window.dispatchEventImpl(Window.java:2750)
at java.awt.Component.dispatchEvent(Component.java:4713)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82) -
As-tu bien chargé la librairie d'oracle dans ton buildpath ?
Sinon sou netbeans :
Clic droit sur ton projet.
Propriétés.
Sur la gauche choisi librairie.
Onglet Compile - clique sur Add Jar/Folder puis sélectionne le .jar
ou
Déplie ton projet.
Clique droit sur librairie.
Puis Add Jar/Folder.
Également vérifie ton adresse de base de donnée.
-