java - UCanAccessSQLException: constraint violation -


i'm having problems java program. i'm using ms access database , ucanaccess connect database.

when i'm trying insert text database, exception:

net.ucanaccess.jdbc.ucanaccesssqlexception: integrity constraint violation: unique constraint or index violation; entries_primarykey table: entries 

this sql statement, results in exception:

"insert entries (text, title, date, time) values"                 + "(\"" + text + "\", \"" + title + "\", \"" + date  + "\", \"" + time + "\");"; 

the primary keys of table entries (title, date). information i'm inserting not exist in table.

i've made system.out.println() containing same string make sure variables contain correct information, , do.

can tell me i'm doing wrong?

(from comment question:)

i tried inserting row, , worked. when tried insert more rows, problem occurred.

if primary key table (title, date) values in 2 columns (fields) must unique across rows. is, can insert row looks like

text        title   date        time ----------  ------  ----------  -------- text   title1  2015-06-01  05:56:15 

but if try insert row this

text        title   date        time ----------  ------  ----------  -------- other text  title1  2015-06-01  06:15:44 

the insert fail because combination of title , date exists in table. yes, row "doesn't exist" because text , time values different, primary key constraint doesn't care; looks @ title , date columns.

if need insert second row you'll need change primary key table.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -