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 7775161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:33:35+00:00 2026-06-01T17:33:35+00:00

I am using MySql with JDBC…the below is my table definition CREATE TABLE `A`

  • 0

I am using MySql with JDBC…the below is my table definition

CREATE TABLE `A` (
  `id` int(255) NOT NULL AUTO_INCREMENT,
  `type` varchar(255) NOT NULL,
  `value` varchar(255) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `unq` (`type`(50),`value`(50))
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

At the moment i am using statement in order to batch insert rows to that table with RETURN_GENERATED_KEYS option in order to relate the id to other table.

I want the ability to perform that operation but when / if DUPLICATE ENTRY occur ( the same combination of type & value ) to continue with the transaction as like nothing happens but still to get the generated keys, and if DUPLICATE ENTRY occur retrieve the existing key.

Thanks

  • 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-06-01T17:33:36+00:00Added an answer on June 1, 2026 at 5:33 pm

    use IGNORE keyword

    INSET IGNORE ....
    

    as Quoted in Mysql

    If you use the IGNORE keyword, errors that occur while executing the
    INSERT statement are treated as warnings instead. For example, without
    IGNORE, a row that duplicates an existing UNIQUE index or PRIMARY KEY
    value in the table causes a duplicate-key error and the statement is
    aborted. With IGNORE, the row still is not inserted, but no error is
    issued.

    alternative syntax

    INSERT … ON DUPLICATE KEY UPDATE

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

Sidebar

Related Questions

I'm using the latest EclipseLink version with MySQL 5.5 (table type InnoDB). I'm inserting
I installed MySql on my own machine. I created database, create table, ... using
I am using following prepared statement : Class.forName(com.mysql.jdbc.Driver); con=DriverManager.getConnection(jdbc:mysql://localhost:3306/mysql,root,root); String query=select ename from ?
I'm new to using JDBC + MySQL. I have several 1/0 values which I
I'm accessing public mySQL database using JDBC and mySQL java connector . exonCount is
I trying to implement the active record pattern using Java/JDBC and MySQL along with
I am using JDBC to query a MySQL database for specific records from two
I am using jdbc to select data from a mysql database. I am performing
I am running a query on a MySQL database, I am using JDBC and
When I insert 78.9 into Mysql (using JDBC) it gets rounded up to 79?

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.