Advertisement
Guest User

Clase Conectar

a guest
Jan 30th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.51 KB | None | 0 0
  1. import java.sql.Connection;
  2. import java.sql.DriverManager;
  3.  
  4.  
  5. /**
  6.  *
  7.  * @author miguelaburto
  8.  */
  9. public class conectar {
  10.    
  11.     Connection conectar=null;
  12.    
  13.     public Connection conexion(){
  14.         try {
  15.             Class.forName("com.mysql.jdbc.Driver");
  16.             conectar=DriverManager.getConnection("jdbc:mysql://localhost/nombre_bbdd?user=root&password=");
  17.         } catch (Exception e) {
  18.             System.out.print(e.getMessage());
  19.         }
  20.         return conectar;
  21.     }
  22.    
  23.    
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement