Filling a linking table with JDBC

I have a linking table between to tables.  The linking table, of course, is a table with primary keys from two tables.

What's the best way to fill the linking table using JDBC?
lcorAsked:
Who is Participating?
 
aozarovConnect With a Mentor Commented:
>> The linking table, of course, is a table with primary keys from two tables.
I assume you are referring to the many-to-many table?

JDBC does not provide you a "special care" for such table.
You will need to populate that table the same way you populate the others.
0
 
CEHJCommented:
Where are you getting the criteria as to how they're linked from?
0
 
lcorAuthor Commented:
Yes, I'm referring to a many to many situation.

CEHJ, this should answer your qeustion.
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
aozarovCommented:
If you need some help with the standard JDBC part you can have a look at: http://www.javaalmanac.com/cgi-bin/search/find.pl?words=executeUpdate
0
 
aozarovCommented:
When you create the link you will need to update "the linking" table as well as the other tables (if you added/remove a new item to them)
0
 
CEHJCommented:
>>CEHJ, this should answer your qeustion.

It doesn't ;-) I'd guessed anyway that you were using many-to-many. My question is how are you finding out how A.id relates to B.id?
0
 
lcorAuthor Commented:
CEHJ ,

I'm not sure how to answer your question.  Can you clarify?

If the two tables have a M:N relationship, how else can I describe it?
0
 
CEHJCommented:
T1:
=========
id field1
=========

T2:
=========
id field1
=========

// Given mapping info of
T1.id=1->T2.id=1,T2.id=2
T2.id=3->T1.id=1,T1.id=2

T1_T2
===========
t1id      t2id
============
1      1
1      2
1      3
2      3

My question is where the 'mapping info' is coming from. Without knowing, it's difficult to advise
0
 
lcorAuthor Commented:
Well, for now it's just being populated manually
0
 
lcorAuthor Commented:
that is simple SQL inserts using Oracle sqlplus
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.