hello I do not know how to insert a date from a JDateChooser into mysql converted for the format that accepts mysql ...... I am working with the MVC fremework ... and I am inserting the data in the following way ....
is my driver class
add a jtxfile just to try to use my application call it
txtFecha2 (this.vistaAlumno.getTxtFecha2().getText())
in the view I made each of the components their GET and SET methods so that I could use them from another class ...
the JDateChooser is called jdFecha.
public void actionPerformed(ActionEvent e) {
if (e.getSource() == vistaAlumno.getBtnInsertar()) {
//obtiene ID de producto this.mimodelo.getDatosVentaxFechas( this.frmconsulta.__fecha1.getDate(), this.frmconsulta.__fecha2.getDate() ) );
//String cat[] = this.vistaAlumno.__lista_categorias.getSelectedItem().toString().split("-");
if (this.modeloAlumno.NuevoProducto(
this.vistaAlumno.getTxtMatricula().getText(),
this.vistaAlumno.getTxtNombre().getText(),
this.vistaAlumno.getTxtApellido_p().getText(),
this.vistaAlumno.getTxtApellido_m().getText(),
this.vistaAlumno.getTxtSexo().getText(),
this.vistaAlumno.getTxtFecha2().getText(),
this.vistaAlumno.getTxtDireccion().getText(),
this.vistaAlumno.getTxtCorreo().getText()// ,
// cat[0].trim()
)) {
this.vistaAlumno.getJtDatosAlumno().setModel(this.modeloAlumno.getTablaAlumno()); //actualiza JTable
JOptionPane.showMessageDialog(null, "Nuevo Alumno Registrado");
} else {
JOptionPane.showMessageDialog(null, "Error: Verifique los datos del nuevo Alumno");
}
greetings and many thanks
well i am not looking at your code but as for adding date from JDateChooser you can use this code
String datee=((JTextField)a.getDateEditor().getUiComponent()).getText();
then you can add it into
ps.setString(0,a);
in the above code,
a is JDateChooser
ps is PreparedStatement
hope it helps
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.