I need to change the date to string format in a PreparedStatemen to insert it in a database

1

Annex my code, the parameter 3 being "txtFecha" is the one that I can not transform:

private void guardar() {
        try {
            PreparedStatement StmGuardar;
            String SQL= "insert into comics(idComics, Titulo, Fecha, Autor, Editorial, Genero, Franquicia, NoEjemplares, Tipo) values (?, ?, ?, ?, ?, ?, ?, ?, ?)";
            StmGuardar = Conex.MiConexion.getConexion().prepareCall(SQL);
            StmGuardar.setInt(1,Integer.parseInt(txtId.getText()));
            StmGuardar.setString(2,txtTitulo.getText());
            //StmGuardar.
            StmGuardar.setString(4,txtAutor.getText());
            StmGuardar.setString(5,txtEditorial.getText());
            StmGuardar.setString(6,txtGenero.getText());
            StmGuardar.setString(7,txtFranquicia.getText());
            StmGuardar.setInt(8,Integer.parseInt(txtEjemplar.getText()));
            StmGuardar.setString(9,txtTipo.getText());
            StmGuardar.executeUpdate();
            JOptionPane.showMessageDialog(rootPane,"Datos insertados correctamente");
        } catch (SQLException e) {
            JOptionPane.showMessageDialog(rootPane,"Error"+e);
        }
    }
    
asked by Raftel666 29.11.2018 в 03:29
source

0 answers