I would not be able to enter a date of birth in my program to fill out a file of a client and save it in the sql database from xampp, I could do it as a string but obviously it does not take the bars "/ " I want to directly load the date and save it in SQL. My code where I load the data are the following:
public void actionPerformed(ActionEvent arg0) {
try {
Class.forName("com.mysql.jdbc.Driver");
java.sql.Connection conexion = DriverManager.getConnection("jdbc:mysql://localhost:3306/tienda","root","");
String nombre = textField_1.getText();
int precio = Integer.parseInt(textField_2.getText());
String descripcion = textArea.getText();
JTextField textField_3 = new JTextField();
SimpleDateFormat form = new SimpleDateFormat("dd/MM/yyyy");
String query = "INSERT INTO productos (nombre,precio,descripcion) values('"+nombre+"','"+precio+"','"+descripcion+"')";
Statement s = conexion.createStatement();
s.executeUpdate(query);
JOptionPane.showMessageDialog(null, "Nombre agregado");
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Error");
// TODO: handle exception
}
}
});