2

I have the following problem. I am inserting data to Postgres database through my javafx interface.

When i import some data to my database, sometimes primary key is violated and I am getting the following stack error:

 catch(PSQLException e){

       System.out.println(e.getLocalizedMessage());
}


 duplicate key value violates unique constraint "importedDocumentPK"
 Detail: Key (part_id, supplier_id, temp_id, qty, color, sign_id, state_id)=(41A213752P9, 750, 7049, 48, 5, 1, 1) already exists.

My question is. How can I save information about this row (41A213752P9, 750, 7049, 48, 5, 1, 1) in my program?

1 Answer 1

1

This information is only available as a text string in the error message in current versions of PostgreSQL. However, the upcoming 9.3 release will expose this as more detailed fields, see http://www.postgresql.org/docs/9.3/static/libpq-exec.html#LIBPQ-PQRESULTERRORFIELD for details. I would assume the JDBC driver will expose the same fields as well, though I'm not sure if they've defined the interface yet.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.