Guest User

Untitled

a guest
Nov 18th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. public void conexionBD() {
  2. try {
  3. try {
  4. Class.forName("com.mysql.jdbc.Driver");
  5.  
  6.  
  7.  
  8. } catch (ClassNotFoundException e) {
  9. System.out.println("Error Driver");
  10. }
  11. Connection connection=null;
  12. connection=DriverManager.getConnection("jdbc:mysql://localhost:3306/servicios", "root", "mysql");
  13. boolean valid=connection.isValid(50000);
  14. System.out.println(valid?"Conexion correcta":"Conexion incorrecta");
  15. } catch (Exception e) {
  16. System.out.println("Error:"+e);
  17. }
  18.  
  19.  
  20.  
  21. }
  22.  
  23.  
  24. public static void main(String[] args) {
  25. PruebaConexion pruebaConexion=new PruebaConexion();
  26. pruebaConexion.conexionBD();
  27.  
  28. }
Add Comment
Please, Sign In to add comment