Ajouter un commentaire

xzéna

voivç le code
package MyProject;

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class Stagiaire{
	static InputStreamReader lecteur;
	static BufferedReader entree;
	static String url = "jdbc:odbc:gestion_stagiaire";
	static Connection con=null; 
	static ResultSet rs=null;
	static boolean rep=false;
	
	void connexion(){
		
	   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
			con = DriverManager.getConnection(url,"","");
		



//içi 1er ereur my frame souligné en rouge--->(erreuer invalid)//
public class MyFrame extends JFrame implements ActionListener{
	
	private JButton add;
	private JButton sup;
	private JButton mod;
	private JButton rech;
	private JButton quitter;
	
	
	
	public MyFrame(){
		super("My Frame");
		JPanel jPanel1 = new JPanel();
		JLabel jLabel = new JLabel();
	    JPanel jPane2 = new JPanel();
	    JLabel jLabe3= new JLabel();
	    JLabel jLabe4 = new JLabel(); 
	    
		add=new JButton ("ajouter");
		sup=new JButton(" Supprimer ");
		mod=new JButton(" Modifier ");
		rech= new JButton ("rechercher");
		quitter= new JButton (" quitter");
		add.addActionListener(this);
		sup.addActionListener(this);
		mod.addActionListener(this);
		rech.addActionListener(this);
		quitter.addActionListener(this);
		
		
		
		
		getContentPane().setLayout(new FlowLayout());
		
		getContentPane().add(add);
		getContentPane().add(sup);
		getContentPane().add(mod);
		getContentPane().add(rech);
		getContentPane().add(quitter);
		JTextField text=new JTextField();
		JTextField text1=new JTextField();
		JTextField text2=new JTextField();
		JTextField text3=new JTextField();
		pack();
		setVisible(true);
		
	}
	
	
	public void afficher_stagiaire() throws SQLException{
		connexion();
		PreparedStatement ps = con.prepareStatement("SELECT * from stagiaire");
		rs = ps.executeQuery();
		while(rs.next()==true){
			System.out.println(rs.getString(1));
			System.out.println(rs.getString(2));
			System.out.println(rs.getString(3));
			System.out.println(rs.getString(4));
			}
		}
	public void actionPerformed(ActionEvent ae){
		if(ae.getSource().equals(add))
			System.out.println("Entrer code Stagiaire");
		String code = entree.readLine();
		PreparedStatement ps = con.prepareStatement("SELECT * from Stagiaire where code_stg = '" + code + "'");
		rs = ps.executeQuery();
		while(rs.next()==true){
			System.out.println(rs.getString(1));
			System.out.println(rs.getString(2));
			System.out.println(rs.getString(3));
			System.out.println(rs.getString(4));
	}
		}

		
			----->//tt cette extrait souligné en rouge,et en utulisant focus-->aucun suggestion!!//
public void supprimer_Stagiaire() throws IOException, SQLException{
			connexion();
			System.out.println("Entrer mat  Stagiaire");
			String code = entree.readLine();
			verifier(code,"SELECT code_stg from Stagiaire");
			if (rep==false){
				System.out.println("Stagiaire Introuvable");}
			else{
			PreparedStatement ps = con.prepareStatement("delete from Stagiaire where code_stg = '" + code + "'");
			ps.executeUpdate();
			System.out.println("Stagiaire  Supprimé");}
			
		}


			public void Ajouter_Stagiaire() throws NumberFormatException, IOException, SQLException{
			connexion();		
String code = entree.readLine();
		verifier(code,"SELECT code_stg from Stagiaire");
		if (rep==true){
			System.out.println("Stagiaire Déja existe");
			}
		else{
		System.out.println("Entrer le nom");
		String nom=entree.readLine();
		System.out.println("Entrer le prenom");
		String prenom=entree.readLine();
		System.out.println("Entrer la date de naissance");
		String dte=entree.readLine();
		System.out.println("Entrer le lieu de naissance");
		String ldte=entree.readLine();
		System.out.println("Entrer l'adresse");
		String adre=entree.readLine();
		System.out.println("Entrer le tel");
		String tel=entree.readLine();
		PreparedStatement ps = con.prepareStatement("insert into Stagiaire values ('" + code + "','" + nom + "','" + prenom + "','" + dte + "','" + ldte + "','" + adre + "','" + tel + "')");
		ps.executeUpdate();
		System.out.println("Stagiaire  Ajouté");}
	}
		/*if(ae.getSource().equals(rech))
			System.out.println("Recherche");
		if(ae.getSource().equals(quitter))
			System.out.println("Quitter");*/


			private void verifier(String code, String string) {
				// TODO Auto-generated method stub
				
			}
		
		
	}
	
	public void main(String[] args){
		new MyFrame();
		
	}
	
	//*public void verifier(String code, String string) {
		// TODO Auto-generated method stub
		
	}*/

TT ça ne done pas de debogae,et les package et main se marquent croix rouge !!! :cry:
Mercii bien

Filtered HTML

Plain text

CAPTCHA
Cette question permet de vérifier que vous n'êtes pas un robot spammeur :-)
  QQQ    BBBB   RRRR   ZZZZZ  V     V 
Q Q B B R R Z V V
Q Q BBBB RRRR Z V V
Q QQ B B R R Z V V
QQQQ BBBB R RR ZZZZZ V
Q