SHARE
TWEET

Untitled

a guest Dec 2nd, 2019 118 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package Conexion;
  7.  
  8. import java.sql.Connection;
  9. import java.sql.DriverManager;
  10.  
  11. /**
  12.  *
  13.  * @author Consultor
  14.  */
  15. public class Conexion {
  16.    
  17.     public static Connection getConexion()
  18.     {
  19.         Connection connection = null;
  20.    
  21.         try
  22.         {
  23.            
  24.             String driverClassName = "com.mysql.jdbc.Driver";
  25.             String driverUrl = "jdbc:mysql://localhost/dsybd";
  26.             Class.forName(driverClassName);
  27.             connection = DriverManager.getConnection(driverUrl, "root", "");
  28.            
  29.             System.out.println("Conexion exitosa.");
  30.        
  31.         } catch(Exception e)
  32.         {
  33.             e.printStackTrace();
  34.             System.out.println("Hubo un error");
  35.         }
  36.    
  37.         return connection;
  38.     }
  39.    
  40.    
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top