Bonjour,
J'essaye de me connecter sur ma base My SQL et je le message d'erreur suivant :
Impossible d'établir la connexion avec la base MySQL : com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
Last packet sent to the server was 0 ms ago.
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
Last packet sent to the server was 0 ms ago.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2104)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:729)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:302)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:283)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.ampli.actuariat.AccesBase.connexionBase(AccesBase.java:206)
at com.ampli.actuariat.AccesBase.instancestate(AccesBase.java:221)
at com.ampli.actuariat.ProgRempHisto.main(ProgRempHisto.java:20)
Caused by: java.net.UnknownHostException: ampli01lnx108
at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$1.lookupAllHostAddr(Unknown Source)
at java.net.InetAddress.getAddressFromNameService(Unknown Source)Problème lors de la recupération de l'objet Statement.
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getAllByName(Unknown Source)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:246)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:276)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2027)
... 14 more
J'ai pourtant bien lié mon projet java a : mysql-connector-java-5.1.5-bin.jar
Mon code incriminé est le suivant :
private static void connexionBase() {
// déclaration et instanciation d'objet
Properties l_parametre = new Properties();
// Récuperation des arguments utile à la connection
l_parametre.put("naming", "sql");
l_parametre.put("prompt", "false");
l_parametre.put("user", "****");
l_parametre.put("password", "*****");
//chargement du pilote
try {
Class.forName(com.mysql.jdbc.Driver.class.getName()).newInstance();
} catch (Exception e) {
System.out.println("Impossible de charger le pilote de MySQL : "+e);
e.printStackTrace();
//throw new ActuariatException("Impossible de charger le pilote de MySQL");
}
// Valorisation des arguments pour la connection
try {
aConnexionBase = DriverManager.getConnection("jdbc:mysql://ampli01lnx108:3306/INTRANET", l_parametre);
//aConnexionBase = DriverManager.getConnection("jdbc:mysql://ampli01lnx108:3306/INTRANET");
} catch (Exception e) {
System.out.println("Impossible d'établir la connexion avec la base MySQL : "+e);
e.printStackTrace();
// throw new ActuariatException("Impossible de'établir la connection avec la base MySQL");
}
}
Est ce que quelqu'un aurait une idée ?
Merci pour votre réponse
Partager