Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help regarding insertion in the database

 
Aditya Vasudeva
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using DB2 as my database manager.

The problem I am facing is that I cannot insert data into multiple tables at the same time. The code is given below:



The data gets inserted into the first table but doesnt get inserted into the 2nd one. It throws an SQLException saying that there is NULL value.

Please help...!!
Waiting for a reply......
 
Campbell Ritchie
Sheriff
Pie
Posts: 49733
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You ought to believe the Exception; you are obviously passing null to a NOT NULL column.
 
Aditya Vasudeva
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the problem is that i have tried inserting data into both the tables seperately. The insertion works fine when inserting into each table seperately!!

It doesnt work when inserting into both tables one after the other.

What do i do now???

Please help !!
 
Campbell Ritchie
Sheriff
Pie
Posts: 49733
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you passing the data in the correct format? If there is any checking for formats (with CHECK CONSTRAINTs or similar) that might convert the data to null.
You appear to have a severely denormalised table, with columns like e-mail which don't depend directly on the primary key. Don't know whether that affects it.

Have you tried passing that String from the command line?

Sorry, can't think of any more suggestions.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic