14

I have learned that JDBC PreparedStatement and PGBouncer can not work together because PreparedStatement uses session pooling and is pre-compiled and PGbouncer uses transactional level pooling.

My question is can createStatement be used with PGBouncer since it is not pre-compiled? and if not can someone point me to another Java api that can connect to the database and can use PGbouncer?

Alfabravo
  • 7,493
  • 6
  • 46
  • 82
user1591668
  • 2,591
  • 5
  • 41
  • 84

1 Answers1

9

PgBouncer FAQ states that while it does not support PreparedStatements to be pooled, you can disable them by adding parameter prepareThreshold=0 into the JDBC connect URL.

This way you keep the benefits of PreparedStatement for other databases you might connect to in the future but still have a working connection through PgBouncer.

dbaston
  • 903
  • 1
  • 10
  • 20
Jan
  • 13,738
  • 3
  • 30
  • 55