Duplicate Records JDBC

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
Web_AdminAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
msk_apkConnect With a Mentor Commented:
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
 
elimesikaCommented:
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
 
Web_AdminAuthor Commented:
Hi,

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

Thanx
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
CEHJCommented:
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
 
Web_AdminAuthor Commented:
actually it inserts same record twice with different primary key where it should be insertted once
0
 
Web_AdminAuthor Commented:
its more like the method on record insert executed twice
0
 
CEHJCommented:
>>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
 
Web_AdminAuthor Commented:
CEHJ:
Yes i know so that I post the questuion in java zone
0
 
CEHJCommented:
Yes, but you've only talked about the table definition and posted no application code. It's an app problem
0
 
CEHJCommented:
No application info provided by the asker
0
 
objectsCommented:
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
 
objectsCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.