?
Solved

Duplicate Records JDBC

Posted on 2010-08-29
13
Medium Priority
?
534 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 2
  • +2
13 Comments
 
LVL 19

Expert Comment

by:elimesika
ID: 33552265
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
ID: 33552271
Hi,

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

Thanx
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 33552357
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
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 

Author Comment

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

Author Comment

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

Expert Comment

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

Author Comment

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

Expert Comment

by:CEHJ
ID: 33552555
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 2000 total points
ID: 33577164
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
ID: 33945504
No application info provided by the asker
0
 
LVL 92

Expert Comment

by:objects
ID: 33953317
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
ID: 33953611
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month14 days, 2 hours left to enroll

800 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