Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQLException - unique values

Posted on 2007-11-19
5
Medium Priority
?
782 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

618 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