?
Solved

Filling a linking table with JDBC

Posted on 2005-05-03
10
Medium Priority
?
252 Views
Last Modified: 2010-03-31
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?
0
Comment
Question by:lcor
  • 4
  • 3
  • 3
10 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 13920366
Where are you getting the criteria as to how they're linked from?
0
 
LVL 15

Accepted Solution

by:
aozarov earned 2000 total points
ID: 13920490
>> 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
 

Author Comment

by:lcor
ID: 13920782
Yes, I'm referring to a many to many situation.

CEHJ, this should answer your qeustion.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 15

Expert Comment

by:aozarov
ID: 13920936
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
 
LVL 15

Expert Comment

by:aozarov
ID: 13920945
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 13921032
>>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
 

Author Comment

by:lcor
ID: 13927290
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 13928337
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
 

Author Comment

by:lcor
ID: 13930535
Well, for now it's just being populated manually
0
 

Author Comment

by:lcor
ID: 13930539
that is simple SQL inserts using Oracle sqlplus
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month15 days, 15 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question