Results 1 to 8 of 8
- 01-13-2011, 09:40 AM #1
Senior Member
- Join Date
- Feb 2009
- Posts
- 117
- Rep Power
- 0
- 01-13-2011, 09:46 AM #2
do you mean insert something into two JTables onscreen at once? Or into two database tables at once?
- 01-13-2011, 11:57 AM #3
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,568
- Rep Power
- 15
Uhm, a trigger?
- 01-13-2011, 12:15 PM #4
Senior Member
- Join Date
- Feb 2009
- Posts
- 117
- Rep Power
- 0
do you mean insert something into two JTables onscreen at once? Or into two database tables at once?
like I have to tables name as customers and account. the customers table would hold customer info, and the account table would hold a primary key 'coming from the customers table' and some info about his account. so if I would add a customer, he would automatically have an account.
Uhm, a trigger?
adding a row at customers table(parent table) would trigger the insertion of a row at the account table(child)
- 01-13-2011, 12:16 PM #5
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,568
- Rep Power
- 15
A trigger is a DB thing. Ask about them at a db forum for your db of choice.
Edit: In any case, your code knows if it is inserting a record, so why don't you simply use a transaction, insert both rows, and then commit.
- 01-13-2011, 12:22 PM #6
Senior Member
- Join Date
- Feb 2009
- Posts
- 117
- Rep Power
- 0
ok, i will try to hit them dudes at the db forum. but what I am after is the primary key that would be created. I would like that to be inserted to a cell in a child table, would that be possible with transactions?
- 01-13-2011, 12:33 PM #7
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,568
- Rep Power
- 15
Then see the API docs for Connection and PreparedStatement. You can create a PreparedStatement in such way as to be able to retreive the newly generated ids.
- 01-13-2011, 12:48 PM #8
Senior Member
- Join Date
- Feb 2009
- Posts
- 117
- Rep Power
- 0
Similar Threads
-
insert multiple rows in the table from List
By Bulelakes in forum JDBCReplies: 2Last Post: 11-15-2010, 02:19 PM -
How to repaint.refresh the table (table model) with combo box selection envent
By man4ish in forum AWT / SwingReplies: 1Last Post: 01-08-2010, 07:19 AM -
inserting multiple rows from one table into another
By xcallmejudasx in forum JDBCReplies: 1Last Post: 04-23-2009, 08:55 PM -
Updating Displayed Table Rows
By raycini in forum JavaServer Faces (JSF)Replies: 2Last Post: 04-20-2009, 09:24 AM -
Color cells and rows in SWT table
By Java Tip in forum SWT TipsReplies: 0Last Post: 07-11-2008, 05:31 PM
Bookmarks