• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Need urgent help in integrity constraints

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I have the following database structure
Table1(field1, field2, field3)
field1 is of type NUMBER(15,2) in Oracle8i and is primary key
Table2(field4,field5)
field4 is of type NUMBER(15,2) in Oracle8i and is a foreign key with references to Table1.field1
I am trying to populate both the tables using JDBC. I am able to successfully populate Table1 but when I populate Table2, I get an exception which says "Integrity Constraint violated-parent key not found", which means the matching value of foreign key is not found in Table1. This is strange because once I populate table1, I retrieve the value of field1 by select command and store it in "double" variable. I pass the same variable in Prepared Statement where I say
pstmt.setDouble(1, variableName).
I have tried that using BigDecimal, Float, Long but no luck. Can someone tell me what is the correct datatype I should store it in? Or anyother suggestion to approach this problem.
A code snippet would definitely help.
Thanks in advance.
 
Yup, yup, yup. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic