public class Conexion {
public String db = "dbventas";
public String url = "jdbc:mysql://127.0.0.1/" + db;
public String user = "root";
public String pass = "root";
public Conexion() {
}
public Connection conectar(){
Connection link = null;
try {
Class.forName("org.gjt.mm.mysql.Driver");
link = (Connection) DriverManager.getConnection(this.url, this.user, this.pass);
} catch (Exception e) {
JOptionPane.showConfirmDialog(null, e);
}
return link;
}
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.