Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I am working with Postgresql database and Java. I am trying to insert into Postgresql database using prepared statement so I am using Batch insert as well. And I am trying to insert 1000 records at a time.

And below is the exception I am getting when I am trying to insert into one of my tables in batches.

java.sql.BatchUpdateException: Batch entry 0 INSERT into data_week (name, address, version, type, size, fax, phone) values('helloooooo', '360 S', '5.0beta4', NULL, '-1', '673', '300') was aborted.  Call getNextException to see the cause.

Does anyone know what does thise error means? And also, can I use batch insert for Postgresql database or not?

EDIT: Below is my schema for the table data_week

CREATE TABLE data_week
(
  name character varying(256),
  address character varying(256),
  version character varying(256),
  type integer,
  size integer,
  fax character varying(256),
  phone integer,
  created_date timestamp without time zone NOT NULL DEFAULT (now() - '7 days'::interval),
  updated_date timestamp without time zone NOT NULL DEFAULT now()
)
share|improve this question
    
In my experience, these exceptions occur when a constraint has been violated. Do you have any constraints which may not be met by one or more records? – Anthony Atkinson Mar 31 '14 at 3:01
    
To add to my previous comment about contraints, I would copy this into a pgAdmin query to see what comes back: INSERT into data_week (name, address, version, type, size, fax, phone) values('helloooooo', '360 S', '5.0beta4', NULL, '-1', '673', '300') – Anthony Atkinson Mar 31 '14 at 3:03
    
The last part of the error message tells you what to do. Did you do it? (Separately, batching isn't very useful in PgJDBC; if you're trying to improve performance use multi-valued inserts and/or COPY instead). – Craig Ringer Mar 31 '14 at 3:09
    
@AnthonyAtkinson, I have separately inserted the values and it did got inserted. That means something else is wrong? – AKIWEB Mar 31 '14 at 3:12
    
Did you call getNextException() as suggested by the error message? If yes, what did the next exception contain? – a_horse_with_no_name Mar 31 '14 at 8:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.