Postgresql:prepared statement "S_1" already exists

近期由于业务需要和一些json的存储查询需要,把新的应用切到pgsql上来,刚刚切好,是可以正常使用的,但是偶尔会来一下

java连接pgsql 偶尔出现 这个错。
 
org.postgresql.util.PSQLException: ERROR: prepared statement "S_1" already exists 
 
检查sql语句,几乎没问题,又看设置,实在找不到哪里有问题
 
百度网上的资料太少了,干脆我写一篇,方便以后遇到此问题的朋友 解决问题,不用翻来覆去找了
 
经过仔细查阅pgbouncer官方文档 
找到了方法
 

Disabling prepared statements in JDBC

The proper way to do it for JDBC is adding prepareThreshold=0 parameter to connect string.

 在配置文件上加上

jdbc.url=jdbc:postgresql://xxxxx:6432/finance_log?prepareThreshold=0

再次启动,S_1这样的错误几乎找不到了。OK

附官方说明
https://pgbouncer.github.io/faq.html#what-should-my-serverresetquery-be

https://jdbc.postgresql.org/documentation/head/connect.html

posted @ 2016-11-05 17:14  yuan.net  阅读(1619)  评论(0编辑  收藏  举报