Recently due to business needs and some JSON storage query needs, the new application cut to pgsql up, just cut, can be normal use, but occasionally will come
Java Connection Pgsql occasionally this error occurs.org.postgresql.util.PSQLException:ERROR:prepared Statement "S_1" already existsCheck SQL statements, almost no problem, and look at the settings, really can't find where there is a problem Baidu online information is too little, simply I write an article, convenient to meet this problem of friends to solve problems, do not have to look over and over again Pgbouncer official documents found the method disabling Prepared statements in JDBC
The proper-to-do it for JDBC are adding prepareThreshold=0 parameter to connect string.
On the configuration file, add
Jdbc.url=jdbc:postgresql://xxxxx:6432/finance_log? preparethreshold=0
Start again, s_1 such errors are almost impossible to find. Ok
Attached official note
https://pgbouncer.github.io/faq.html#what-should-my-serverresetquery-be
Https://jdbc.postgresql.org/documentation/head/connect.html
postgresql:prepared statement "S_1" already exists