Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6384921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:50:06+00:00 2026-05-25T02:50:06+00:00

I insert alot of data into a table with a autogenerated key using the

  • 0

I insert alot of data into a table with a autogenerated key using the batchUpdate functionality of JDBC. Because JDBC doesn’t say anything about batchUpdate and getAutogeneratedKeys I need some database independant workaround.

My ideas:

  1. Somehow pull the next handed out sequences from the database before inserting and then using the keys manually. But JDBC hasn’t got a getTheNextFutureKeys(howMany). So how can this be done? Is pulling keys e.g. in Oracle also transaction save? So only one transaction can ever pull the same set of future keys.

  2. Add an extra column with a fake id that is only valid during the transaction.

  3. Use all the other columns as secondary key to fetch the generated key. This isn’t really 3NF conform…

Are there better ideas or how can I use idea 1 in a generalized way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:50:06+00:00Added an answer on May 25, 2026 at 2:50 am

    Partial answer

    Is pulling keys e.g. in Oracle also transaction save?

    Yes, getting values from a sequence is transaction safe, by which I mean even if you roll back your transaction, a sequence value returned by the DB won’t be returned again under any circumstances.

    So you can prefetch the id-s from a sequence and use them in the batch insert.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When doing an INSERT with a lot of data, ie: INSERT INTO table (mediumtext_field)
Like: insert into table (col) values (N'multilingual unicode strings') I'm using SQL Server 2008
In PHP, I want to insert into a database using data contained in a
i want to insert some data into a data table, for a wordpress plugin.
I have triggers that manipulate and insert a lot of data into a Change
i have a problem in inserting some data into a table. I have done
I'm using MySQLdb to upload a lot of data from text files into a
I'm trying to aggregate some customer order data into one table for analysis. The
I have a process that imports a lot of data (950k rows) using inserts
I want to create and insert a lot of images into a PDF and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.