Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package reservadehotel;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- import javax.swing.JOptionPane;
- public class conexion {
- private static Connection cnx = null;
- public static Connection obtener() {
- if (cnx == null) {
- try {
- Class.forName("com.mysql.jdbc.Driver");
- cnx = DriverManager.getConnection("jdbc:mysql://localhost:3306/granhotelvyd", "root", "");
- } catch (SQLException ex) {
- } catch (ClassNotFoundException ex) {
- throw new ClassCastException(ex.getMessage());
- }
- }
- return cnx;
- }
- public static void cerrar() throws SQLException {
- if (cnx != null) {
- cnx.close();
- }
- }
- public Connection getConnection() {
- throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
- }
- }
Add Comment
Please, Sign In to add comment