aspose file tools*
The moose likes JDBC and the fly likes how to insert into 2 tables at a time? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "how to insert into 2 tables at a time?" Watch "how to insert into 2 tables at a time?" New topic
Author

how to insert into 2 tables at a time?

david hongw wang
Greenhorn

Joined: Mar 28, 2006
Posts: 6
JDBC EDB Tomcat
--------------------------
when I built up the Database, I seperate a customer's information into 2 tables in 1 database.

when I get customer's information from a html form, I try to insert these information into 2 tables at the same time, the 2 tables have a cust_id as the same coloum,
-----------------------
the question is:
how can I control when inserting the data, if one of the sql failed, the other successed one could roll back?
stu derby
Ranch Hand

Joined: Dec 15, 2005
Posts: 333
Originally posted by david hongw wang:
JDBC EDB Tomcat
--------------------------
when I built up the Database, I seperate a customer's information into 2 tables in 1 database.

when I get customer's information from a html form, I try to insert these information into 2 tables at the same time, the 2 tables have a cust_id as the same coloum,
-----------------------
the question is:
how can I control when inserting the data, if one of the sql failed, the other successed one could roll back?


Using a database that properly supports transactions (many but not all):



If your database doesn't support transactions, then it's real real hard and I don't want to hurt my brain tonight trying to remember how to do that. In fact, there are enough free and cheap databases that do support transactions correctly that there's no point in wasting good brain cells on the problem.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to insert into 2 tables at a time?