The moose likes JDBC and the fly likes  Need urgent help in integrity constraints Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JDBC
Reply Bookmark " Need urgent help in integrity constraints" Watch " Need urgent help in integrity constraints" New topic
Author

Need urgent help in integrity constraints

Mike Dafel
Greenhorn

Joined: Jul 12, 2001
Posts: 10
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.
 
 
subject: Need urgent help in integrity constraints
 
Threads others viewed
Composite Foreign Key that maps to Unique Constraint
Any one have idea regarding this query??
Problem with joining of two tables with Hibernate
database design help needed
I want to join three tables using DetachedCriteria
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture