I have two table CUSTOMER as parent and PROFILE as child with one to many relationship.I want to insert and select data fro开发者_运维百科m both table simultaneously how?
Since u are using jdbc , to select parent and child write a join in mysql ,for example like below:
Select cust.id,cust.name,prof.id,prof.name from Customer cust join profiler prof on cust.profid=prof.id
The INSERT statement inserts into a single table. To insert rows into two tables, you'll need to use two separate INSERT statements. Place them inside a transaction to ensure that either both are completed, or neither is completed.
You may find this useful: http://download.oracle.com/javase/tutorial/jdbc/index.html
精彩评论