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

huangapple go评论71阅读模式
英文:

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

问题

在尝试通过JDBC在pgbouncer数据库上发出“SHOW POOLS”或任何统计查询命令时,遇到以下异常。

org.postgresql.util.PSQLException: 错误:不支持的pkt类型:80

org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2270)

org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1998)

org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)

org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:570)

org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:406)

org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:286)

JDBC代码:

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

JDBC驱动程序版本:42.2.14;
PgBouncer版本:1.14.0;
Postgres版本:11.4;

PS:
可以手动连接到pgbouncer数据库并发出所有pgbouncer管理员命令,例如SHOW POOLSSHOW STATS。只是无法从JDBC执行相同的操作。

英文:

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

得分: 1

JDBC默认使用扩展查询协议,请尝试对于这种查询使用简单协议。

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

PGBouncer当前仅支持简单协议 - 数据包类型80用于'Parse',这是扩展协议的第一步。您在PSQLException异常中看到的消息实际上来自PGBouncer。

英文:

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.

huangapple
  • 本文由 发表于 2020年7月22日 20:46:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/63034558.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定