[clos] ClassNotFoundException

Fermé
dmo83 Messages postés 79 Date d'inscription vendredi 19 août 2011 Statut Membre Dernière intervention 11 octobre 2011 - 12 sept. 2011 à 12:12
cs_Julien39 Messages postés 6414 Date d'inscription mardi 8 mars 2005 Statut Modérateur Dernière intervention 29 juillet 2020 - 12 sept. 2011 à 14:05
bonjours!jè compilé mon programme mè il affiche ça:
Error(201,9): exception java.lang.ClassNotFoundException is never thrown in body of corresponding try statement
je ne comprend pas aide moi
voici le code:
//afficher les données enregistrer dans une table
private void afficher_actionPerformed(ActionEvent e) {
Connection conn = null;
ResultSet rs = null; Statement st=null;
try{
// Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql:/127.0.0.1/BD_PRODUIT?user=root" ;

//class.forName("org.gjt.mm.mysql.Driver");
conn = DriverManager.getConnection(url);

String requete = "select* from PRODUIT";
st =conn.createStatement();
rs = st.executeQuery(requete);

while(rs.next()){

System.out.println(rs.getString("ref")+" "+rs.getString("designation")+" "+rs.getDouble("prix") );

}

}

catch(ClassNotFoundException ex){
//System.out.println("MAUVAIS PILOTE");
JOptionPane.showMessageDialog(null,"MAUVAIS PILOTE","Erreur",JOptionPane.ERROR_MESSAGE);
}



catch(SQLException se){
//System.out.println("SQL INCORRECTE");
JOptionPane.showMessageDialog(null,"sql incorrecte","Erreur",JOptionPane.ERROR_MESSAGE);

}

finally{
if(st!=null){
try{
st.close();
}
catch(SQLException el){
el.printStackTrace();
}
}

if(rs!=null){
try{
rs.close();
}
catch(SQLException se){
se.printStackTrace();
}
}

if(conn!=null){
try{
conn.close();
}
catch(SQLException se){
se.printStackTrace();
}
}
}


}

bigboss

1 réponse

cs_Julien39 Messages postés 6414 Date d'inscription mardi 8 mars 2005 Statut Modérateur Dernière intervention 29 juillet 2020 371
12 sept. 2011 à 14:05
Bonjour,

Pour les autres réponses c'est ici : http://www.javafr.com/forum/sujet-CATCH-CLASSNOTFOUNDEXCEPTION_1546207.aspx

@dmo83 : tu postes beaucoup de messages en double et sans forcément donner suite aux réponses qui ont été données. Pourrais tu à l'avenir poser tes questions sur un seul sujet et répondre à celui-ci sans forcément en ouvrir un autre.
0
Rejoignez-nous