Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. package unsch.efpis.ConexionDB;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.SQLException;
  6.  
  7. /**
  8.  *
  9.  * @author sin_querer
  10.  */
  11. public class Conexion {
  12.     private static Connection cn = null;
  13.     private static String URL = "jdbc:mysql://localhost:3306/mydb";
  14.     private static String usuario = "root";
  15.     private static String contrasena = "123456";
  16.    
  17.     public static Connection getConexion() throws SQLException {
  18. DriverManager.registerDriver(new com.mysql.jdbc.Driver());
  19.         cn = DriverManager.getConnection(URL, usuario, contrasena);
  20.         return cn;
  21.     }
  22. }