insertion dans oracle 10g xe depuis java
salut tout le monde.
je suis nouvelle sur ce forum et je suis débutante en java.
j'ai un probleme d'insertion des données depuis un swing dans ma table qui se trouve dans la bd par défaut xe de oracle 10g. voici mon code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
| import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.sql.*;
public class client extends JPanel implements ActionListener{ JPanel Bou = new JPanel();
JPanel Boutons = new JPanel();
JPanel Bouton = new JPanel();
JButton ok = new JButton("ok");
JButton annuler = new JButton("annuler");
JButton client = new JButton("nouveau client");
JLabel ab1=new JLabel("Nom ");
JLabel ab2=new JLabel("Prenom");
JTextField abonne1=new JTextField(10);
JTextField abonne2=new JTextField(10);
JFrame win;
client(JFrame win){
this.win=win;
setLayout(new BorderLayout(40,40));
Boutons.add(ok);
Bouton.add(ab1);
Bouton.add(abonne1);
Bou.add(ab2);
Bou.add(abonne2);
Boutons.add(annuler);
add(Bouton,BorderLayout.WEST);
add(Bou,BorderLayout.EAST);
add(Boutons,BorderLayout.SOUTH);
ok.addActionListener(this);
annuler.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == annuler) {
win.dispose();
}
else if (e.getSource() == ok) {
String nom1=abonne1.getText();
String prenom1=abonne2.getText();
Connection conn;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "hyposse", "amir");
Statement stmt = conn.createStatement();
String hyp="insert into Client_Abonne (code,nom,prenom) values (CLIENT.nextval,'"+nom1+"','"+prenom1+"')";
ResultSet rset = stmt.executeQuery (hyp);
hyp ="select client.currval from dual";
int resultSet = stmt.executeUpdate(hyp);
boolean poi=rset.next();
String he=rset.getString(1);
JFrame Cade=new JFrame();
Cade.setContentPane(new code(he,Cade));
Cade.setLocation(280,150);
Cade.pack();
Cade.setVisible(true);
win.dispose();
}
catch (ClassNotFoundException f) {
System.err.println("Ne peut trouver la classe du driver de la base de donnees.");
f.printStackTrace();
}
catch (SQLException f) {
System.err.println("Probleme SQL.");
f.printStackTrace();
}
}
}
} |
et voici le msg d'exception:
Citation:
Probleme SQL.
java.sql.SQLSyntaxErrorException: ORA-00942: Table ou vue inexistante
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:447)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:951)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:513)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:227)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:531)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:195)
at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:1036)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1336)
at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1498)
at oracle.jdbc.driver.OracleStatementWrapper.executeQuery(OracleStatementWrapper.java:406)
at client.actionPerformed(client.java:64)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
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:6505)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
at java.awt.Component.processEvent(Component.java:6270)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4861)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
at java.awt.Container.dispatchEventImpl(Container.java:2273)
at java.awt.Window.dispatchEventImpl(Window.java:2719)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:729)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:688)
at java.awt.EventQueue$3.run(EventQueue.java:686)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:702)
at java.awt.EventQueue$4.run(EventQueue.java:700)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:699)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
svp j'ai besoin de votre aide; je suis bloqué pcq apparemment je ne trouve pas d'erreur.
merci d'avance