This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem: SQL Exception
 
Similar Threads
How to Validate duplicate entries in database using struts1
jsp insert into database error(java.lang.NumberFormatException: For input string: "")
How to display error message
how to do validation in struts1
Doubt in Validating the values form database