bonjour
je suis en train de developper avec netbeans
dans mon projet j'ai un module de connexion à une base de donnees mysql.
J'ai ajouté la library "MySQL JDBC Driver" et par contre elle n'a pas été reconnue.
Qu'est-ce que je dois ajouter ?
merci d'avance
voici mon code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 // définitions des paramètres de connexion.... String pilote = "com.mysql.jdbc.Driver";//DRIVER String host = "jdbc:mysql://localhost:3306/gestionpatient";//PATH String login = "";// USER String pw = "";//PASSWORD String requete="SELECT numpatient,nom,prenom FROM fichecommune ";
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 public JDBCAdapter(String driverName,String url, String user, String passwd) { try { Class.forName(driverName); System.out.println("Opening db connection"); connection = DriverManager.getConnection(url, user, passwd); //statement = connection.createStatement(); statement = connection.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE ); } catch (ClassNotFoundException ex) { System.err.println("Cannot find the database driver classes."); System.err.println(ex); } catch (SQLException ex) { System.err.println("Cannot connect to this database."); System.err.println(ex); } }run:
Cannot find the database driver classes.
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
There is no database to execute the query.
BUILD SUCCESSFUL (total time: 3 seconds)
Partager