当尝试通过 JDBC 对 pgbouncer 数据库发出“SHOW POOLS”或任何统计查询命令时,面临以下异常。
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代码:
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;
附:
能够手动连接到 pgbouncer 数据库并发出所有 pgbouncer 管理命令,例如表演池 or 显示统计数据。只是无法从 JDBC 执行相同的操作。
JDBC默认使用扩展查询协议,此类查询可尝试使用简单协议
String connectionUrl = "jdbc:postgresql://"+ipaddress+":"+port+"/"+database+"?preferQueryMode=simple";
PGBouncer 目前支持only简单协议 - 数据包类型 80 用于“解析”,这是扩展协议的第一步。您在异常 PSQLException 中看到的消息实际上来自 PGBouncer。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)