Está en la página 1de 1

/* * To change this template, choose Tools | Templates * and open the template in the editor.

*/ package clase; import import import import import java.sql.Connection; java.sql.DriverManager; java.sql.SQLException; java.util.logging.Level; java.util.logging.Logger;

public class conexion { public static String usuario="root"; public static String clave="123"; public static String servidor="localhost"; public static String BD="bdsiges"; public static Connection crearConexion() { Connection con=null; try { try { Class.forName("com.mysql.jdbc.Driver").newInstance(); } catch (InstantiationException ex) { Logger.getLogger(conexion.class.getName()).log(Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { Logger.getLogger(conexion.class.getName()).log(Level.SEVERE, null, ex); } String URL="jdbc:mysql://"+servidor+"/"+BD; con=DriverManager.getConnection(URL, usuario,clave); } catch(java.lang.ClassNotFoundException e) { System.out.println("classnotfound"); } catch(SQLException e) { System.out.println("error de enlace canal"); } return con; } }