英文:
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 POOLS或SHOW 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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论