Guest User

Untitled

a guest
Dec 14th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. public class configurasion {
  2.  
  3.  
  4. public TextField Puerto;
  5. public TextField base;
  6. public TextField servidor;
  7.  
  8. public String CONEXION_STRING = "jdbc:mysql://127.0.0.1:3306/proyecto";
  9. public String USUARIO = "root";
  10. public String PASSWORD = "";
  11. private static Connection conexion;
  12.  
  13.  
  14. public void configurasion(MouseEvent mouseEvent) {
  15.  
  16. abrirConexion();
  17.  
  18. }
  19. public static Connection getConexion() {
  20. return conexion;
  21. }
  22.  
  23.  
  24.  
  25. private void abrirConexion() {
  26.  
  27.  
  28. try {
  29. conexion = DriverManager.getConnection(CONEXION_STRING, USUARIO, PASSWORD);
  30. } catch (SQLException e) {
  31. JOptionPane.showMessageDialog(null, "La conexion no se realizo exitosamente: " + e.getMessage());
  32. }
  33. JOptionPane.showMessageDialog(null, "Conexion a base de datos exitosa ");
  34. }
  35.  
  36.  
  37. public void atras(MouseEvent mouseEvent) {
  38. try {
  39.  
  40. Parent root = FXMLLoader.load(getClass().getResource("../Vistas/ingresarDatos.fxml"));
  41. Scene scene = new Scene(root);
  42. Stage anterior = (Stage) ((Node) mouseEvent.getSource()).getScene().getWindow();
  43. anterior.setScene(scene);
  44. anterior.show();
  45. } catch (IOException ex) {
  46. Logger.getLogger(configurasion.class.getName()).log(Level.SEVERE, null, ex);
  47. }
  48.  
  49.  
  50. }
  51.  
  52.  
  53. }
Add Comment
Please, Sign In to add comment