voila mon 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
 
import java.sql.*;
 
 public class TestJdbc4
 {
 
 public static void main (String[] args)
 {Connection connexion=null;
 Statement instruction=null;
 ResultSet resultat=null;
 ResultSetMetaData data = null;
  int nbcol = 0;
  int i = 0;
 
 
 String pilote="com.mysql.jdbc.Driver";
 
 try{
System.out.println("ça va ");
Class.forName(pilote);
System.out.println("ça va forNAME ");
 connexion = DriverManager.getConnection("jdbc:mysql:///taxiphone", "root","");  //magasin c'est le nom de ma base
 System.out.println("ça va CONNEXION ");
 instruction = connexion.createStatement();
 //System.out.println("ça va  STATEMNET");
 resultat = instruction.executeQuery("select * from utilisateur ");
 //System.out.println("ça va REQUETTE");
 data = resultat.getMetaData();
 nbcol = data.getColumnCount();
 
 for(i = 0; i < nbcol; i++){
  //System.out.println("ça va LA BOUCLE DES COLONNES ");
 System.out.print(data.getColumnName(i+1)+" | ");
 }
 System.out.println();
 while(resultat.next()){
  for(i = 0; i < nbcol; i++){
   //System.out.println("ça va DES ENREGISTREMENTS");
   System.out.print(resultat.getString(i+1)+"   |     ");
      }
      System.out.println();
 }
}
 catch (ClassNotFoundException e){        //ces deux execptions qu'il faut catché sinon vous aurez un pb ClassNot..et SQLEx..)
 
 System.out.println("Class not found : "+e);
 }
 catch(SQLException m){                      
  System.out.println("Jdbc failure");
 }
 finally{
 
    try{
     if(resultat != null)
      resultat.close();
     if(instruction != null)
      instruction.close();
     if(connexion != null)
      connexion.close();
       }
      catch(SQLException ex){
       ex.printStackTrace();
      }
     }
 
 }}
je comprend pas pourquoi j'arrive pa à me connecter à ma base de données crees sous easyphp