繁体   English   中英

将日期从JDateChooser插入到MySql数据库

[英]Insert date from a JDateChooser to a MySql database

你好,我不知道如何将JDateChooser中的日期插入到已转换为mysql格式的mysql中……我正在使用MVC fremework ...,并且正在以以下方式插入数据.. ..

是我的司机课

添加一个jtxfile只是为了尝试使用我的应用程序调用它

txtFecha2 (this.vistaAlumno.getTxtFecha2().getText())

在视图中,我将每个组件都设置为GET和SET方法,以便可以从另一个类中使用它们...

JDateChooser称为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");
            }

问候和非常感谢

好吧,我不是在看您的代码,但是关于从JDateChooser添加日期,您可以使用此代码

String datee=((JTextField)a.getDateEditor().getUiComponent()).getText();

然后可以将其添加到

ps.setString(0,a);

在上面的代码中,

一个是JDateChooser

ps是PreparedStatement

希望能帮助到你

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM