?
Solved

SQLException - unique values

Posted on 2007-11-19
5
Medium Priority
?
781 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
[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
5 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 1000 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses
Course of the Month15 days, 14 hours left to enroll

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