aspose file tools*
The moose likes JDBC and the fly likes Problem: SQL Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Problem: SQL Exception" Watch "Problem: SQL Exception" New topic
Author

Problem: SQL Exception

Simon John
Greenhorn

Joined: Jan 04, 2002
Posts: 20
Sql Exception is thrown : java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] You cannot add or change a record because a related record is required in table 'BATCH'.

BATCH TABLE
------------
BATCHID TEXT (PRIMARY KEY)
STUDENT TABLE
-------------
FIRSTNAME TEXT
LASTNAME TEXT
YEARID TEXT
SECTION TEXT
ROLLNO TEXT (PRIMARY KEY)
BATCHID TEXT (PRIMARY KEY)
DEPTCODE TEXT (PRIMARY KEY)
ADDRESS TEXT
PHONENO TEXT
MOBILENO TEXT
EMAIL TEXT
GENDER TEXT
PASSWORD TEXT
ENROLLMENTNO TEXT
"INSERT INTO STUDENT ( FIRSTNAME , LASTNAME , YEARID , SECTION , ROLLNO , BATCHID , DEPTCODE , ADDRESS , PHONENO ,MOBILENO , EMAIL , GENDER , PASSWORD , ENROLLMENTNO ) VALUES ('"+firstName+"', '"+lastName+"', '"+yearID+"', '"+section+"', '"+rollNo+"', '"+batchID+"', '"+deptCode+"', '"+ address+"', '"+phoneNo+"', '"+mobileNo+"', '"+emailAddress+"', '"+gender+"', '"+password+"', '"+enrollmentNo+"')";
The value of the batch ID that i m passing in the above query in already present in the Batch Table
Simon John
Greenhorn

Joined: Jan 04, 2002
Posts: 20
I have solved the problem
 
jQuery in Action, 2nd edition
 
subject: Problem: SQL Exception