ma question est toute simple: mon programme ne s'execute pas correctement,
c'est juste un petit formulaire qu'il faut remplir et capter les informations pour les mettre dans une base de données.
sachant que quand je fait des SELECTça marche trés bien
mais les insertions.........
merci d'avance

code:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
 
import java.lang.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.sql.*;
 
 
 
 
public class Armateur  extends JFrame implements ActionListener  {
	    int   code1;
	    String nom1;
	    String prenom1;
	    String adresse1;
	    int NumTel1;
	    JTextField entree1;
	    JTextField entree2;
	    JTextField entree3;
	    JTextField entree4;
	    JTextField entree5;
	    public Armateur()
	    {super("Fiche Armateur #");
	    Constructeur();
	    }
 
 
        private void Constructeur(){
	    setSize(500,100);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setLocationRelativeTo(null);//centrer la fenetre
 
 
	    /*---------Creation d'un paneau --------------*/
		JPanel panel = new JPanel();
		GridLayout disposition = new GridLayout(2,2);
		panel.setLayout(disposition);
 
 
		/*---------Création d'un label----------------*/
		JLabel label1 = new JLabel("Code :");
		label1.setPreferredSize(new Dimension(70,20));
		panel.add(label1);
 
		/*---------Création d'une zone de texte-------*/
		 entree1 = new JTextField(30);
		entree1.setPreferredSize(new Dimension(10,20));
		panel.add(entree1);
	//	code1 = entree1.getText();
 
 
		/*---------Création d'un label----------------*/
		JLabel label2 = new JLabel("Nom :");
		label2.setPreferredSize(new Dimension(70,150));
		panel.add(label2);
 
		/*---------Création d'une zone de texte-------*/
	  entree2 = new JTextField(30);
		entree2.setPreferredSize(new Dimension(100,20));
		panel.add(entree2);
	//	nom = entree2.getText();
 
		/*---------Création d'un label----------------*/
		JLabel label3 = new JLabel("Prenom :");
		label3.setPreferredSize(new Dimension(70,150));
		panel.add(label3);
 
		/*---------Création d'une zone de texte-------*/
		 entree3 = new JTextField(30);
		entree3.setPreferredSize(new Dimension(100,20));
		panel.add(entree3);
	//	prenom = entree3.getText();
 
		/*---------Création d'un label----------------*/
		JLabel label4 = new JLabel("Adresse :");
		label4.setPreferredSize(new Dimension(70,150));
		panel.add(label4);
 
		/*---------Création d'une zone de texte-------*/
		 entree4 = new JTextField(30);
		entree4.setPreferredSize(new Dimension(100,20));
		panel.add(entree4);
	//	adresse = entree4.getText();
 
		/*---------Création d'un label----------------*/
		JLabel label5 = new JLabel("N° téléphone :");
		label5.setPreferredSize(new Dimension(70,150));
		panel.add(label5);
 
		/*---------Création d'une zone de texte-------*/
	    entree5 = new JTextField(30);
		entree5.setPreferredSize(new Dimension(100,20));
		panel.add(entree5);
//		NumTel = entree5.getText();
 
		/*---------Création d'un bouton-------*/
		JButton BT = new JButton("valider"); 
		BT.addActionListener(this);
		BT.setPreferredSize(new Dimension(70,20));
		panel.add(BT);
 
		this.setContentPane(panel);
 
	    } //Fin du constructeur
 
 
 
 
       //--------Gestion des actions ------------------------- 
      public void actionPerformed(ActionEvent evt) 
       {if (evt.getSource()instanceof JButton)  
       {String ChoixOption = evt.getActionCommand();     
       if (ChoixOption.equals("valider"))
          {
 
            int code1 = Integer.parseInt(entree1.getText());
	        	nom1 = entree2.getText();
	        	prenom1 = entree3.getText();
	       	    adresse1 = entree4.getText();
	       	    int NumTel1 = Integer.parseInt(entree5.getText());
	       	    String insertString = "INSERT INTO armateur (code, nom,prenom,adresse, num_tel)"+
	             "VALUES"+ "("+code1+","+nom1+","+ prenom1+","+adresse1+","+NumTel1+")";
 
          	 try{
 
          		Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");	
        	    Connection con = DriverManager.getConnection("jdbc:odbc:karima","sa","g16a10m18");
	            Statement stmt = con.createStatement();
 
 
	             System.out.println(insertString);
                 // stmt.executeUpdate("select * from region");
              	stmt.executeUpdate(insertString);
        	}
	       catch( ClassNotFoundException e) {
           System.err.println("Erreur lors du chargement du pilote : " + e);
           }
           catch(SQLException sqle) {
           System.err.print("Erreur SQL : " + sqle);}     
 
        }
 
           }
 
       }
 
 
 
        public static void main(String[] args)
        {Armateur AR = new Armateur();//Rendre le cadre visible
         AR.setVisible(true);
          }
 }