This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Import data from database with sequence as primary key  RSS feed

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI all,

I want to import data from another database using JDBC. All the tables have sequence as the primary key and the sequences on the source and destination need not match. I want to enter data into 'N' related tables (having the sequence column as the foreign key) in a single transaction. What is the best approach to achieve this?

Thanks in advance

 
Preeti Prabhakar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, let me make my question more clear.
I have a Java application (job) which receives data for multiple tables from another schema. These tables have DB sequence as the primary key. Now I want to replicate the data from this schema onto my schema using a Java program. How can i handle sequences and Foreign key references to these sequences while executing the java job?

Thanks in advance.
 
Marshal
Posts: 60073
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Preeti,

in which format your job receives the input data? is it Flat file or delimited file or Excel or some other?

whatever it may be, in the output schema why do you bother about the sequence of the input schema.
Just consider that as input field and persist in your resultant DB schema. If you want you can make that column as PK.

If you have FK columns, first in the referred table then referring table.

 
Preeti Prabhakar
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Krish for the response...

I get the input as a flat file.

Say, I have 3 related tables... Student -> Student_Address -> Location. Each of these tables have Sequence as primary key.
I have to import data for all the 3 tables in the same transaction. Is it possible?

Thanks
 
krish laks
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Preeti,

I assume Student and Location are independent tables. And Student_Address is dependent on both these tables.
Also from your mail I understand you will get Student_id (PK of student table), Location_id (PK of Location table).
So, you first insert these two tables and then insert the Student_Address table.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!