Mar 15th, 2013, 12:47 PM
Spring batch- Postgresql prepared statement error
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
Last edited by vishalravishankar; Mar 15th, 2013 at 12:49 PM.
Reason: additional information
Mar 18th, 2013, 03:44 PM
What ItemWriter are you using for this?
Mar 19th, 2013, 05:43 AM
I am using IbatisBatchItemWriter.
Originally Posted by mminella
Mar 19th, 2013, 08:26 AM
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
Mar 19th, 2013, 08:35 AM
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.
Mar 19th, 2013, 08:54 AM
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
Tags for this Thread