Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void conexionBD() {
- try {
- try {
- Class.forName("com.mysql.jdbc.Driver");
- } catch (ClassNotFoundException e) {
- System.out.println("Error Driver");
- }
- Connection connection=null;
- connection=DriverManager.getConnection("jdbc:mysql://localhost:3306/servicios", "root", "mysql");
- boolean valid=connection.isValid(50000);
- System.out.println(valid?"Conexion correcta":"Conexion incorrecta");
- } catch (Exception e) {
- System.out.println("Error:"+e);
- }
- }
- public static void main(String[] args) {
- PruebaConexion pruebaConexion=new PruebaConexion();
- pruebaConexion.conexionBD();
- }
Add Comment
Please, Sign In to add comment