Guest User

Untitled

a guest
Dec 4th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. package reservadehotel;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.SQLException;
  6. import javax.swing.JOptionPane;
  7.  
  8.  
  9. public class conexion {
  10.  
  11. private static Connection cnx = null;
  12. public static Connection obtener() {
  13. if (cnx == null) {
  14. try {
  15. Class.forName("com.mysql.jdbc.Driver");
  16. cnx = DriverManager.getConnection("jdbc:mysql://localhost:3306/granhotelvyd", "root", "");
  17. } catch (SQLException ex) {
  18.  
  19. } catch (ClassNotFoundException ex) {
  20. throw new ClassCastException(ex.getMessage());
  21. }
  22. }
  23. return cnx;
  24. }
  25. public static void cerrar() throws SQLException {
  26. if (cnx != null) {
  27. cnx.close();
  28. }
  29. }
  30.  
  31. public Connection getConnection() {
  32. throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
  33. }
  34. }
Add Comment
Please, Sign In to add comment