Meaningless Drivel is fun!*
The moose likes JDBC and the fly likes Help regarding insertion in the database 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 "Help regarding insertion in the database" Watch "Help regarding insertion in the database" New topic
Author

Help regarding insertion in the database

Aditya Vasudeva
Ranch Hand

Joined: May 27, 2008
Posts: 76
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

Joined: Oct 13, 2005
Posts: 37884
    
  22
You ought to believe the Exception; you are obviously passing null to a NOT NULL column.
Aditya Vasudeva
Ranch Hand

Joined: May 27, 2008
Posts: 76
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

Joined: Oct 13, 2005
Posts: 37884
    
  22
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help regarding insertion in the database
 
Similar Threads
java.sql.SQLException: Result set is in an invalid state. May be before the first row or after the
Database access, potential threading problem?
SQLException while registrering driver
Access to the Oracle database using Java Applets
How to create SQL server2005 database on remote machine using jdbc?