1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
package accidentologie;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class Test {
public static void main(String args[]) {
String url = "jdbc:mysql://localhost:3306/site";
String identifiant = "root";
Connection con = null;
try {
con = DriverManager.getConnection(url, identifiant, " ");
System.out.println("OK");
} catch (Exception e) {
System.out.println("Erreur lors de la récupération de la connexion : " + e.getMessage());
} finally {
try {
if (con != null) {
con.close();
}
} catch (Exception e) {
}
}
}
} |