• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Weird error

 
Ranch Hand
Posts: 445
Android Eclipse IDE Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using JSP/Servlet to develop a Web application...I had a table had 17 fields..At the first form user wants to fill only 8 forms..Whereas the table has 3 foreign key fields and user left one of them...When i try to insert the foreign key value which the user left, by storing the word "NULL" in a string and add it by ps.setString(10,var).. it compiles but it shows a weird error says

: Code Edited :
Ranchers, please let me know whats the problem and help me fix this error....
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Cannot add or update a child row: a foreign key constraint fails
(`raj1/tbl_rmadetails`, CONSTRAINT `fk_raj1tbl_vendortbl` FOREIGN KEY (`VENDOR_I
D`) REFERENCES `tbl_vendor` (`vendor_id`) ON DELETE NO ACTION ON UPDATE NO ACTIO
N)"


Your insert or update action violates this foreign key. I would assume that whatever your are inserting does not have a vendor_id, but if you check what that FK requires you should be able to work out what is missing.
 
Rajkumar balakrishnan
Ranch Hand
Posts: 445
Android Eclipse IDE Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Paul Sturrock:

Your insert or update action violates this foreign key. I would assume that whatever your are inserting does not have a vendor_id, but if you check what that FK requires you should be able to work out what is missing.



How to find what the FK needs?
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This depends on your database and the database tools you have. Which are you using?
 
Rajkumar balakrishnan
Ranch Hand
Posts: 445
Android Eclipse IDE Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I use MySQL.... and JSP/Servlet as my dev tool...
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think mysqldump will show you the DDL for a foreign key. You could try that.
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

 
Can you hear that? That's my theme music. I don't know where it comes from. Check under this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic