Solved

Duplicate Records JDBC

Posted on 2010-08-29
13
525 Views
Last Modified: 2012-05-10
Hello experts,

I want to know what the cause of inserting duplicate records where it should insert one record only in JDBC? my primary key is auto increment and how can i avoid this
0
Comment
Question by:Web_Admin
  • 4
  • 4
  • 2
  • +2
13 Comments
 
LVL 19

Expert Comment

by:elimesika
Comment Utility
HI

1) What DB you are using ?

2) What is the type of your Primary Key

3) Do you have any UNIQUE index on the table ?
0
 

Author Comment

by:Web_Admin
Comment Utility
Hi,

1) my DB is oracle 10g
2) Numeric auto increment
3) no

Thanx
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
Can you post the result of this query?
SELECT table_name, index_name, column_name FROM dba_ind_columns WHERE table_name = 'yourtable';

Open in new window

0
 

Author Comment

by:Web_Admin
Comment Utility
actually it inserts same record twice with different primary key where it should be insertted once
0
 

Author Comment

by:Web_Admin
Comment Utility
its more like the method on record insert executed twice
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
>>actually it inserts same record twice with different primary key where it should be insertted once

That's a different record then. Sounds like the error is in your application, not the db
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:Web_Admin
Comment Utility
CEHJ:
Yes i know so that I post the questuion in java zone
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
Yes, but you've only talked about the table definition and posted no application code. It's an app problem
0
 
LVL 4

Accepted Solution

by:
msk_apk earned 500 total points
Comment Utility
It could be the problem in the application. May be you shall define some static integer in your code which takes care of identifying the number of times that insert code is getting executed. Just print that static integer and try to match the real insert count with the count it prints.

Or enable database logging say for example mysql logging can be enabled through --log parameter and see number of queries getting exected and their values.
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
No application info provided by the asker
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
wouldn't this come under "If you are not getting the kinds of responses that will lead to a solution, you should consider deleting your question and trying again."
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
Web_Admin,

Add some logging to the code that does the insert to get an idea when it is getting executed
perhaps also a stack trace so you know where it is being called from
http://helpdesk.objects.com.au/java/how-to-store-exception-stack-trace-as-string
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

743 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now