no save
Assistance
Achat
News

Forum | programmation
Connection a Mysql via java
-=(L)=-, le jeu. 08 févr. 2007 à 10:00:13
Salut les gens,

Je commence en java alors soyez gentils plzzzzz :-)

J'essai de me connecter a ma base de donner Mysql en passant par un programme en java développé sous eclipse dont voici le code :



import java.sql.*;

class affichage{

public static void main(String[] args){

String pilote = "com.mysql.jdbc.Driver";

try{
Class.forName(pilote);

Connection connexion = DriverManager.getConnection("jdbc:mysql://localhost/test","root","pass");

Statement instruction = connexion.createStatement();

ResultSet resultat = instruction.executeQuery("SELECT * FROM ANNONCE");
while(resultat.next()){


System.out.println("---------------------------");
System.out.println("N° ID_ANNONCE: "+resultat.getInt("ID_ANNONCE"));
System.out.println("N° ID_MODELE: "+resultat.getInt("ID_MODELE"));
System.out.println("Descriptif: "+resultat.getString("DESCRIPTIF"));

}
}
catch (Exception e){

System.out.println("echec pilote : "+e);
}

}
}



Il me semble avoir bien placer mes pilote mysql mais je suis pas sur ( je les ais mis la où il y a mon code java).

Et voici ce que cela m'affiche :
echec pilote : java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

Auriez-vous une solution a me proposé siouplé.


-=(L)=-
févr. 07
Suivant
REPONSES
layoin
sept. 08
Luciano
nov. 08
mougaref
18 févr.
verty
20 avr.
Mery18
15 mai
Hamid
17 mai
astrocybernaute
26 mai
hamid
27 mai
astrocybernaute
28 mai
superseb801
08 sept.
Version Web
Réalisé par RedShift
no save