35 lines
746 B
Java
35 lines
746 B
Java
package modelo;
|
|
|
|
import java.sql.Connection;
|
|
import java.sql.DriverManager;
|
|
import java.sql.SQLException;
|
|
|
|
public class Database {
|
|
private Connection conexion;
|
|
|
|
public Database() {
|
|
conectar();
|
|
}
|
|
|
|
private void conectar() {
|
|
try {
|
|
conexion = DriverManager.getConnection("jdbc:mysql://localhost:3306/venta_boletos", "root", "4560");
|
|
} catch (SQLException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
public Connection getConexion() {
|
|
return conexion;
|
|
}
|
|
|
|
public void cerrarConexion() {
|
|
try {
|
|
if (conexion != null) {
|
|
conexion.close();
|
|
}
|
|
} catch (SQLException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
} |