Insert data from a JTextField to MySQL

0

I would like to be able to help me with links, information, etc. that will help me to recover this: I have a jtxtField that I want to enter the information of is to the database in MYSQL and I really do not know how to do it. I have the connection ready, this is working correctly.

public class MysqlCon {

    public static void connect(){
    String url = "jdbc:mysql://--------/mltev";
    String user = "-------";
    String pass = "-------";
    System.out.println("Conectando...");
    try(Connection connection = DriverManager.getConnection(url, user,pass)){
    System.out.println("Conectado!!");

    }catch(SQLException e){
        System.out.println(e.getMessage());
    }
    }   
}

And my JTextField is this:

    left.gridy = right.gridy = 5;
    this.add(new JLabel("Nombre corto:"), left);
    nombrecorto = new javax.swing.JTextField("");
    this.add(nombrecorto, right);

The next thing I show is the code I'm using to listen to the events of the tab change, since when I switch to the Calibration tab in some way (I do not understand how, the code is not mine) the data that I enter in the previous tab where the jtextfield is "saved"

    calibratePanel = new CalibratePanel(this);
    tabs.addTab("Calibrate", null, calibratePanel, "Calibrate OMR");
    // setMnemonicAt(0, KeyEvent.VK_1);
     calibratePanel.setBackground(colorAzul);
    tabs.addChangeListener(calibratePanel); 

I leave my code here, in case someone can help me

link

Key:! Egl1gPijhQdE50KharRL_bWZdKgHJ2XFozFlBzOzww4

    
asked by Letty Lopez 11.06.2018 в 23:07
source

0 answers