Insert a record in 2 related tables

0
 String cod,mod,cat,des,pre,stock;
        String sql="";
        cod=txtcod.getText();
        mod=txtmode.getText();
        cat=cboCateg.getSelectedItem().toString();
        des=txtdes.getText();
        pre=txtpre.getText();
        stock=txtstock.getText();
        sql="INSERT INTO producto (id_producto, id_categoria, modelo, descripcion, precio, stock) VALUES (?,?,?,?,?,?)";


    try {
        PreparedStatement pst  = cn.prepareStatement(sql);
        pst.setString(1, cod);
        pst.setString(2, mod);
        pst.setString(3, cat);
        pst.setString(4, des);
        pst.setString(5, pre);
        pst.setString(6, stock);
        int n=pst.executeUpdate();
        if(n>0){
        JOptionPane.showMessageDialog(null, "Registro Guardado con Exito");
        bloquear();
        }

    } catch (SQLException ex) {
        Logger.getLogger(IngresoProductos.class.getName()).log(Level.SEVERE, null, ex);
    }

[ I would like to know how I can do the query to insert the name of the category in my 2 tables

    
asked by Arthur 02.02.2017 в 06:28
source

0 answers