========================================
public class ConexionDB {
private static final String DRIVER = "com.mysql.cj.jdbc.Driver";
private static final String DB = "dbtest";
private static final String URL = "jdbc:mysql://localhost:3306/";
private static final String USER = "root";
private static final String PASSWORD = "";
public static Connection getConnection() {
Connection conn = null;
try {
Class.forName(DRIVER);
conn = DriverManager.getConnection(URL + DB, USER, PASSWORD);
private static final String DB = "dbtest";
private static final String URL = "jdbc:mysql://localhost:3306/";
private static final String USER = "root";
private static final String PASSWORD = "";
public static Connection getConnection() {
Connection conn = null;
try {
Class.forName(DRIVER);
conn = DriverManager.getConnection(URL + DB, USER, PASSWORD);
System.out.println("Successful Connection! ");
} catch (ClassNotFoundException e) {
System.out.println("Driver not found for database");
} catch (SQLException e) {
System.out.println("Failed Connection!" + e.getMessage());
System.out.println("Driver not found for database");
} catch (SQLException e) {
System.out.println("Failed Connection!" + e.getMessage());
}
return conn;
}
}
return conn;
}
}
No hay comentarios:
Publicar un comentario