I am trying to insert some simple values into a table, but when I use ” INSERT INTO phones VALUES(default, ‘2546543453’, ‘cell phone’); ” in my Java code, I get the following error:
Exception in thread “main” org.postgresql.util.PSQLException: ERROR: duplicate key violates unique constraint “pk_phones”
I have also tried to insert with: “INSERT INTO phones(phoneid, phoneno, description) VALUES(default, ‘2546543453’, ‘phone’);” But, when I substitute a valid primary key instead of the keyword default, it works fine.
The schema is:
phones(phoneID SERIAL, phoneno TEXT, description TEXT);
I am also using Hibernate3 to map my objects, and if I simply try to save the Phone object into the database using Hibernate3, it works fine as well. However, I want to perform more complex inserts, updates, and queries simply using JDBC, but am running into the above problem using the keyword “default”. If anyone knows a way to work around this (besides retrieving each tuple, totalling them, and then adding 1), I would appreciate it greatly.
Thanks,
Sean