Postgres报告Coltype -7(位)但合格名称Bool
我使用 jdbc 元数据读取列的类型。
使用此 java 代码,
columns = metadata.getColumns(catalogName, schema.getName(), table.getName(), "%");
while (columns.next()) {
final String fqtn = columns.getString(6);
int type = columns.getInt(5);
LOG.fine("Column '" + table.getName() + "." + columnName + "' is type: " + type + " and of fqtn:" + fqtn + "!");
}
我记录以下输出:
Column 'BUILD_RESULT.finished' is type: -7 and of fqtn:bool!
我查看 java.sql.Types
并寻找 -7 并找到 BIT
所以输入 -7 是 BIT
但名称被报告布尔
。
BIT 和 BOOL 之间有一个区别:
- BIT 可以是
0
或1
- BOOL 可以是
true
或false
。
当 java.sql.Types
中有更好的匹配类型 16 (BOOLEAN) 时,为什么会报告位 (-7)?
我安装了一个 sql-manager 并检查字段 BUILD_RESULT.finished,如下所示:
它是布尔值,而不是位。为什么 postgres jdbc 告诉我它是一个 BIT?
编辑:添加 jdbc-jar 的版本
我没有 jar 名称,但我有清单信息:
Manifest-Version: 1.0
Bnd-LastModified: 1455914805118
Build-Jdk: 1.8.0_66
Built-By: vladimirsitnikov
Bundle-Activator: org.postgresql.osgi.PGBundleActivator
Bundle-Copyright: Copyright (c) 2003-2015, PostgreSQL Global Development
Group
Bundle-Description: Java JDBC 4.1 (JRE 7+) driver for PostgreSQL databas
e
Bundle-DocURL: http://jdbc.postgresql.org/
Bundle-License: http://www.postgresql.org/about/licence/
Bundle-ManifestVersion: 2
Bundle-Name: PostgreSQL JDBC Driver JDBC41
Bundle-SymbolicName: org.postgresql.jdbc41
Bundle-Vendor: PostgreSQL Global Development Group
Bundle-Version: 9.4.1208.jre7
并且 select version()
说:x86_64-pc-linux-gnu 上的 PostgreSQL 9.4.25 ( Ubuntu 9.4.25-1.pgdg18.04+1),由gcc编译(Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0, 64 位
I read the type of a column using the jdbc metadata.
Using this java-code
columns = metadata.getColumns(catalogName, schema.getName(), table.getName(), "%");
while (columns.next()) {
final String fqtn = columns.getString(6);
int type = columns.getInt(5);
LOG.fine("Column '" + table.getName() + "." + columnName + "' is type: " + type + " and of fqtn:" + fqtn + "!");
}
I log this output:
Column 'BUILD_RESULT.finished' is type: -7 and of fqtn:bool!
I look into java.sql.Types
and looking for -7 and found BIT
So type -7 is BIT
but name is reported bool
.
There is a difference between BIT and BOOL:
- BIT can be
0
or1
- BOOL can be
true
orfalse
.
Why is bit (-7) reported when there is a better matching type 16 (BOOLEAN) in java.sql.Types
?
I installed a sql-manager and inspect the field BUILD_RESULT.finished like this:
It is boolean, not bit. Why is postgres jdbc telling me it is a BIT?
EDIT: Add version of jdbc-jar
I do not have the jar-name but I have the Manifest's info:
Manifest-Version: 1.0
Bnd-LastModified: 1455914805118
Build-Jdk: 1.8.0_66
Built-By: vladimirsitnikov
Bundle-Activator: org.postgresql.osgi.PGBundleActivator
Bundle-Copyright: Copyright (c) 2003-2015, PostgreSQL Global Development
Group
Bundle-Description: Java JDBC 4.1 (JRE 7+) driver for PostgreSQL databas
e
Bundle-DocURL: http://jdbc.postgresql.org/
Bundle-License: http://www.postgresql.org/about/licence/
Bundle-ManifestVersion: 2
Bundle-Name: PostgreSQL JDBC Driver JDBC41
Bundle-SymbolicName: org.postgresql.jdbc41
Bundle-Vendor: PostgreSQL Global Development Group
Bundle-Version: 9.4.1208.jre7
And select version()
said: PostgreSQL 9.4.25 on x86_64-pc-linux-gnu (Ubuntu 9.4.25-1.pgdg18.04+1), compiled by gcc (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0, 64-bit
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该错误从7年以来就无法解决: https://githbc.com/pgjdbc/pgjdbc/pgjdbc/pgjdbc/issues/ 367
信用到@a_horse_with_no_name
The bug is unsolved since 7 years: https://github.com/pgjdbc/pgjdbc/issues/367
Credits to a @a_horse_with_no_name