Vous êtes sur la page 1sur 1

26/2/2018 conexion.

java

C:\Users\GioMemo\Documents\NetBeansProjects\SistemaCalibracion\src\Logica\conexion.java

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 Logica;
7
8 import java.sql.Connection;
9 import java.sql.DriverManager;
10 import java.sql.SQLException;
11 import javax.swing.JOptionPane;
12
13 /**
14 *
15 * @author GioMemo
16 */
17 public class conexion {
18 public String db="dbcalibracion";
19 public String url="jdbc:mysql://127.0.0.1/"+db;
20 public String user="root";
21 public String pass="";
22
23 public conexion() {
24 }
25
26 public Connection conectar(){
27 Connection link=null;
28
29 try {
30 Class.forName("org.gjt.mm.mysql.Driver");
31 link=DriverManager.getConnection(this.url, this.user, this.pass);
32 } catch (ClassNotFoundException | SQLException e) {
33 JOptionPane.showConfirmDialog(null, e);
34 }
35 return link;
36 }
37
38 }
39

file:///C:/Users/GioMemo/Desktop/conexion.html 1/1

Vous aimerez peut-être aussi