String SQL="INSERT INTO tbl_rmadetails (date,rma_no,customer_id,item_id,customer_inv_no,customer_inv_date,customer_inv_amount,serial_no,fault_desc,replaced_serial_no,status,vendor_id,vendor_invoice_no,vendor_inv_date,vendor_rma_ref,remarks) VALUES(str_to_date(da,'%m/%d/%Y'),?,cust,ite,?, str_to_date(date1,'%m/%d/%Y'),?,?,fdesc,?,stat,?,?,?,?,?)";
Hi friends.. i use the above syntax to insert some values into Database from my JSP page. when i execute this it shows java.sql.NullPointerException.. The problem is three of the field(item_id,customer_id,vendor_id) is foreign key where in my form i enter only 2 of these fields ie) i leave one foreign key field empty. Can i do this? If not then suggest me some other options.. Any help would be appreciated
Never try to be a hard-worker. Be a smart-worker.
Yes, you can leave fields, including foreign keys null, as long as it makes sense in the database. You may want to skip setting a value on these fields since the problem may be casued by the null field itself.
After analysing your query, it seems you are trying to insert a null value from Jsp to Database.(Same as you said). See David's comment carefully If you are sure that one field(Foreign key column) would be empty, then avoid that column from your Insert statement.It will automatically add the null value. Don't try to insert that from Jsp.
Regards Baseet Ahmed ############## Value of Parents Jannat(Heaven) is under the feet of Mother. Father is the middle gate of Jannat(Heaven). [ ISLAM ] ##############
Hi friends, I analyze the problem and try to insert the foreign key values by loading those foreign key values in the combo box of that corresponding JSP page. But even now i have a NPE that for the primary key field. How do insert a primary key field without getting any input from user. I try the following code but it not works fine.. Here is my code ------------------