Results 1 to 6 of 6

Thread: Spring batch- Postgresql prepared statement error

  1. #1

    Default Spring batch- Postgresql prepared statement error

    Hi,
    In my use case I have to insert information in postgresql tables.I am using the ibatis to insert to tables, but when I am trying to run the job, I am getting prepared statement error(ERROR: prepared statement "S_1" already exists). I tried to google out the answer and found there is an issue in Postgresql driver, but it is suggested in one of the link to deallocate the previous prepared statement, but I could not find the how to implement the deallocation through batch. Any help would be appreciated.

    EDIT:The version of Batch I am using is 2.0.4

    Thanks
    Vishal
    Last edited by vishalravishankar; Mar 15th, 2013 at 12:49 PM. Reason: additional information

  2. #2
    Join Date
    Sep 2008
    Location
    Chicagoland, IL
    Posts
    351

    Default

    What ItemWriter are you using for this?
    Michael Minella
    Spring Batch Lead
    Author - Pro Spring Batch
    http://www.michaelminella.com
    Twitter: @MichaelMinella

  3. #3

    Default

    Quote Originally Posted by mminella View Post
    What ItemWriter are you using for this?
    I am using IbatisBatchItemWriter.

  4. #4
    Join Date
    Sep 2008
    Location
    Chicagoland, IL
    Posts
    351

    Default

    After some googling, this seems to be a postgres issue. Are you using the PgBouncer connection pool (or can you post your configuration)? If so, this post seems to be in line with your issue: http://stackoverflow.com/questions/7...already-exists
    Michael Minella
    Spring Batch Lead
    Author - Pro Spring Batch
    http://www.michaelminella.com
    Twitter: @MichaelMinella

  5. #5

    Default

    Yes, its the same issue as mentioned in the link.is there any way out from spring batch where we can manage connection in batch instead from postgresql.

  6. #6
    Join Date
    Sep 2008
    Location
    Chicagoland, IL
    Posts
    351

    Default

    We definitely don't want to get into mucking with connections under iBatis. My advice would be to either use a different connection pool that supports prepared statements or go to session pooling. Session pooling may be ok in batch since we open one session per call to the itemWriter (essentially honoring the same boundaries as transaction pooling would) but I'll admit I haven't tried it.

    The Wiki page for PgBouncer states that the connection pool does not support prepared statements in transaction pooling mode: http://wiki.postgresql.org/wiki/PgBouncer
    Michael Minella
    Spring Batch Lead
    Author - Pro Spring Batch
    http://www.michaelminella.com
    Twitter: @MichaelMinella

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •