Solved

SQLException - unique values

Posted on 2007-11-19
5
775 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This video teaches viewers about errors in exception handling.

839 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