Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package xml;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- public class Conexion {
- private static String servidor ="jdbc:mysql://localhost";
- private static String user="root";
- private static String pass="";
- private static String driver="com.mysql.jdbc.Driver";
- private static Connection Conexion;
- public Conexion(String base){
- try{
- if(base!=null){
- servidor= servidor + "/"+base;
- }
- Class.forName(driver);
- Conexion=DriverManager.getConnection(servidor, user, pass);
- } catch(ClassNotFoundException | SQLException e){
- System.out.println("fallo de conexion con la base de datos");
- }
- }
- public Connection getConnection(){
- return Conexion;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement