Probléme dans ma methode inscription!
etudiantepg
Messages postés
12
Date d'inscription
Statut
Membre
Dernière intervention
-
etudiantepg Messages postés 12 Date d'inscription Statut Membre Dernière intervention -
etudiantepg Messages postés 12 Date d'inscription Statut Membre Dernière intervention -
voila j'ai ma classe Connect :
puis j'ai ma methode inscription qui se trouve ds ma classe client:
bref quand jexecute tout est okayy; jusqu'au niveau coucou 4 tout s'arréte
donc ma requéte ne s'execute pas car coucou 5 ne s'affiche pas je me demande pk :s !!!
ps : mn probléme se trouve dans l'invocation je crois!
package agence; import java.sql.*; public class Connect { public Connection con; public Statement st; public ResultSet rs; public Connect() throws ClassNotFoundException, SQLException{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("jdbc:odbc:Agence_location","",""); System.out.println("connection ok"); } public void fermer() throws SQLException{ con.close(); st.close(); rs.close(); } public ResultSet etablirC(String requete)throws SQLException { st= con.createStatement(); ResultSet rs = st.executeQuery(requete); System.out.println("rs ok"); return rs; } public int etablirCo(String requete) throws SQLException { st= con.createStatement(); int r = st.executeUpdate(requete); System.out.println("dacc"); return r; } }
puis j'ai ma methode inscription qui se trouve ds ma classe client:
public class clientIImpl extends clientIPOA{ ArrayList<voiture> voitures= new ArrayList(); voiture[] voit; String query; String query1; String query3; String quer; public String inscrire(client c) throws ClientInscrit { int id=c.id; String nom=c.nom; String num=c.num_tel; try{ Connect c1= new Connect(); query="select * from TabClient where Nom='"+nom+"'"; ResultSet rs=c1.etablirC(query); System.out.println(" coucou 1 "); System.out.println(rs.next()); System.out.println("coucou 2"); if(rs.next()){ System.out.println("coucou 3"); throw( new ClientInscrit(" Déjà Inscrit !!"));} else{System.out.println("coucou 4"); query1="insert into TabClient(identifiant,Num_tel,Nom) values (id,num,nom)"; System.out.println("coucou 5"); c1.etablirCo(query1); System.out.println("coucou c fini"); String g="Vous êtes maintenant inscrit !"; return g; }} catch(ClassNotFoundException |SQLException e){ return "Erreur ! ";} } main : public static void main(String[]args)throws ClassNotFoundException, SQLException{ Connect ccc=new Connect(); clientIImpl g = new clientIImpl(); // ma classe Scanner sc=new Scanner(System.in); System.out.println("entrez votre numero de telephone:"); String a=sc.nextLine(); Scanner sc1=new Scanner(System.in); System.out.println("entrez votre identifiant:"); short a1=(short) sc1.nextInt(); Scanner sc2=new Scanner(System.in); System.out.println("entrez votre Nom:"); String a2=sc2.nextLine(); client cd = new client(a1,a,a2,false); try { g.inscrire(cd); } catch (ClientInscrit e) { System.out.println("bbbbbbb"); // TODO Auto-generated catch block e.printStackTrace(); }
bref quand jexecute tout est okayy; jusqu'au niveau coucou 4 tout s'arréte
donc ma requéte ne s'execute pas car coucou 5 ne s'affiche pas je me demande pk :s !!!
ps : mn probléme se trouve dans l'invocation je crois!
A voir également:
- Probléme dans ma methode inscription!
- Wetransfer gratuit sans inscription - Guide
- Twitter inscription - Guide
- Vinted inscription - Guide
- Paypal inscription - Guide
- Instagram inscription - Guide