Solved

SQLException - unique values

Posted on 2007-11-19
5
768 Views
Last Modified: 2012-06-27
i am getting the following exception for my SQL statement

java.sql.SQLException: Violation of unique constraint $$: duplicate value(s) for column(s) $$: SYS_PK_52

create table statement shown below:

what sql syntax lets me allow to store duplicate values?? .. thou i'm sure of not having duplicate values for my columns.. but for large dataset, it throws the exception

thanks


DBTableFunctions.createTableFromString("CREATE CACHED TABLE "+tableName+" ("+"ImageID VARCHAR(256) PRIMARY KEY, "+colNames+") CREATE UNIQUE INDEX IMAGEID_INDEX ON "+tableName+"(ImageID)");

Open in new window

0
Comment
Question by:max_dub
5 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 250 total points
ID: 20317188
Take out UNIQUE
DBTableFunctions.createTableFromString("CREATE CACHED TABLE "+tableName+" ("+"ImageID VARCHAR(256) PRIMARY KEY, "+colNames+") CREATE INDEX IMAGEID_INDEX ON "+tableName+"(ImageID)");

Open in new window

0
 
LVL 23

Expert Comment

by:cmalakar
ID: 20317772
Remove the PRIMARY KEY on the column..
 
Primary key make sures the column, contains values which are not null and not duplicated.
0
 
LVL 25

Expert Comment

by:imitchie
ID: 20318504
is the sqlexception being thrown in createTableFromString? or are you just showing the table create code, whereas the failing code is elsewhere?
0
 

Author Comment

by:max_dub
ID: 20319053
i thought the exception was occuring due to unique index being create during createtable statement, hence i showed the create table statement

it cud be somewhere else also.. but i am sure.. where can it be getting duplicate values.. i double checked all my rows have unique filename, rest of 100 col. have floating point values..

i am debugging it right now!

thou i did remove the remove the Create Unique Index from create table statement

0
 

Author Comment

by:max_dub
ID: 20321795
with just primary key it works fine - no errors whole day
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Creating and Managing Databases with phpMyAdmin in cPanel.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
The viewer will learn how to implement Singleton Design Pattern in Java.

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

15 Experts available now in Live!

Get 1:1 Help Now