PgBouncer throwing PSQLException: ERROR: unsupported pkt type: 80 when issuing query "SHOW POOLS" on "pgbouncer" database via JDBC

Viewed 227

When trying to issue "SHOW POOLS" or any stats query command on pgbouncer database via JDBC, facing the below exception.

org.postgresql.util.PSQLException: ERROR: unsupported pkt type: 80
    at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2270)
    at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1998)
    at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
    at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:570)
    at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:406)
    at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:286)

JDBC code:

String connectionUrl = "jdbc:postgresql://"+ipaddress+":"+port+"/"+database; 
con = DriverManager.getConnection(connectionUrl, userName, password);
statement = con.createStatement(); statement.executeQuery("SHOW POOLS");



JDBC Driver Version: 42.2.14 ;
PgBouncer Version: 1.14.0 ;
Postgres Version: 11.4;

PS: Manually able to connect to pgbouncer database and issue all pgbouncer admin commands like SHOW POOLS or SHOW STATS. Just not able to execute the same from JDBC.

1 Answers

JDBC use extended query protocol by default, try simple protocol for such query

String connectionUrl = "jdbc:postgresql://"+ipaddress+":"+port+"/"+database+"?preferQueryMode=simple"; 

PGBouncer currently supports only the simple protocol - the packet type 80 is for 'Parse', which is the first step in the extended protocol. The message you see in the exception PSQLException actually comes from PGBouncer.

Related