Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8479489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:02:23+00:00 2026-06-10T19:02:23+00:00

Am trying to get some order information from XML file and trying to store

  • 0

Am trying to get some order information from XML file and trying to store it in database(MySQL) table. I can retrieve the order information from XML file but when am trying to insert into the table it shows error as MySQLIntegrityConstraintException.

My program contains as below,

def Order = new XmlParser().parse("MyXml.xml")
def set1 = sql.dataSet("order_item")
def set2 = sql.dataSet("order_header")
Order.order_item.each {
// retrieving order information and storing
}
set1.add(Column_Name1:order_id,Column_Name2:field2,Column_Name3:field3)
set2.add(Column_Name1:order_id)

I listed the error in detail below

WARNING: Failed to execute: insert into order_item (order_id, order_item_seq_id,
order_item_type_id, product_id, prod_catalog_id, quantity, unit_price, unit_lis
t_price, item_description, status_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) beca
use: Cannot add or update a child row: a foreign key constraint fails (ecommerc
e/order_item
, CONSTRAINT ORDER_ITEM_HDR FOREIGN KEY (ORDER_ID) REFERENCES
order_header
(ORDER_ID))
Caught: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationExcepti
on: Cannot add or update a child row: a foreign key constraint fails (ecommerce
/order_item
, CONSTRAINT ORDER_ITEM_HDR FOREIGN KEY (ORDER_ID) REFERENCES o
rder_header
(ORDER_ID))
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cann
ot add or update a child row: a foreign key constraint fails (ecommerce/order_i
tem
, CONSTRAINT ORDER_ITEM_HDR FOREIGN KEY (ORDER_ID) REFERENCES order_hea
der
(ORDER_ID))
at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
at com.mysql.jdbc.Util.getInstance(Util.java:384)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1041)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3562)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3494)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1960)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2114)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2696)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.ja
va:2105)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java
:2398)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java
:2316)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java
:2301)
at db2xml.XMLToDatabase$_main_closure2.doCall(XMLToDatabase.groovy:52)
at db2xml.XMLToDatabase.main(XMLToDatabase.groovy:38)

Can anyone help me to come out from this problem. Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T19:02:25+00:00Added an answer on June 10, 2026 at 7:02 pm

    At first the foreign key constraint table to be updated initially then the specific table to should me updated. A small change in the above code is

    set2.add(Column_Name1:order_id)
    set1.add(Column_Name1:order_id,Column_Name2:field2,Column_Name3:field3)

    The set 2 should updated first and then the set 1.

    Now it got worked for me. Thanks for all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just trying to get some rows out of a database and loop through but
Im trying to get some system information using WMI but the problem is when
I am trying to get information from 3 tables in my database. I am
I'm trying to get some data from a certain web-based api using the libcurl
I am trying to check a field in some XML that is returned from
Here is my basic situation. I'm trying to use NHibernate to get information from
I'm trying to create a table of information in a database query using Zend
I've trying to create some stats for my table but it has over 3
I am trying to query a database to return some matching records and can't
Im trying to get some auto complete to work. I have this URL i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.