Mysql avec eclipse
laurent2403
Messages postés
79
Date d'inscription
Statut
Membre
Dernière intervention
-
laurent2403 -
laurent2403 -
Bonjour,
voila je n'arrive pas a me connecter a ma base de donnée mysql , pour accéder a ma bd je passe par XAMP , j'ai mis le driver dans le java build path (mysql-connector-java-2.0.14-bin)
voici ma classe et merci beaucoup pour votre travail...
package base_de_donnees;
import java.sql.*;
public class Connection_Mysql {
public static void main(String[] args) {
String pilote = "com.mysql.jdbc.Driver";
try {
Class.forName(pilote);
System.out.println("driver etablie");
} catch (ClassNotFoundException e) {
System.out.println("driver not found");
e.printStackTrace();
}
try {
@SuppressWarnings("unused")
Connection connexion = DriverManager.getConnection(
"jdbc:mysql://localhost/test", "root", "pass");
System.out.println("connexion base mysql etablie");
} catch (SQLException e) {
System.out.println("pas de connexion");
e.printStackTrace();
}
}
}
voila ce me met la console:
Exception in thread "main" java.sql.SQLException: Communication failure during handshake. Is there a server running on localhost:3306?
at com.mysql.jdbc.MysqlIO.init(Unknown Source)
at com.mysql.jdbc.Connection.connectionInit(Unknown Source)
at com.mysql.jdbc.jdbc2.Connection.connectionInit(Unknown Source)
at com.mysql.jdbc.Driver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
voila je n'arrive pas a me connecter a ma base de donnée mysql , pour accéder a ma bd je passe par XAMP , j'ai mis le driver dans le java build path (mysql-connector-java-2.0.14-bin)
voici ma classe et merci beaucoup pour votre travail...
package base_de_donnees;
import java.sql.*;
public class Connection_Mysql {
public static void main(String[] args) {
String pilote = "com.mysql.jdbc.Driver";
try {
Class.forName(pilote);
System.out.println("driver etablie");
} catch (ClassNotFoundException e) {
System.out.println("driver not found");
e.printStackTrace();
}
try {
@SuppressWarnings("unused")
Connection connexion = DriverManager.getConnection(
"jdbc:mysql://localhost/test", "root", "pass");
System.out.println("connexion base mysql etablie");
} catch (SQLException e) {
System.out.println("pas de connexion");
e.printStackTrace();
}
}
}
voila ce me met la console:
Exception in thread "main" java.sql.SQLException: Communication failure during handshake. Is there a server running on localhost:3306?
at com.mysql.jdbc.MysqlIO.init(Unknown Source)
at com.mysql.jdbc.Connection.connectionInit(Unknown Source)
at com.mysql.jdbc.jdbc2.Connection.connectionInit(Unknown Source)
at com.mysql.jdbc.Driver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
A voir également:
- Eclipse mysql
- Eclipse java - Télécharger - Langages
- Mysql community server - Télécharger - Bases de données
- Mysql a répondu : documentation connexion impossible : paramètres incorrects. - Forum Bases de données
- Eclipse temurin jdk avec hotspot ✓ - Forum Java
- Mysql fatal error ✓ - Forum MySQL
2 réponses
bonjour,
Tu devrais ajouter le jar de connection mysql au java build path, je pense c'est ça l'origine de l'erreur. Pour faire voici les étapes à suivre :
Bouton droit sur le projet, cliquer sur propriétés -->java build path --> librairies -->add external jars--> et choisis ton jar mysql.
J'espère ça résoud ton problème?
Tu devrais ajouter le jar de connection mysql au java build path, je pense c'est ça l'origine de l'erreur. Pour faire voici les étapes à suivre :
Bouton droit sur le projet, cliquer sur propriétés -->java build path --> librairies -->add external jars--> et choisis ton jar mysql.
J'espère ça résoud ton problème?