DBVisualizer 在保存“0001-01-01”的日期字段上显示空值
DBVisualizer displays null on date field holding '0001-01-01'
我在 DbVis 中发布了一个 SQL 语句:
select vestdate, name from person where vestdate is not null
并得到许多结果,其中 DbVisualizer 将授权日期显示为 (null)
!
经过调查,我发现授权日期是 '0001-01-01'
,因此查询正确返回了这些记录,但 DbVisualizer 显示 它们为 (null)
。
我刚刚从 windows 8 切换到 windows 10。
它适用于 windows 8(显示“0001-01-01”),但不适用于 windows 10(显示空):
Product: DbVisualizer Pro 11.0.4 [Build #3103]
OS: Windows 8.1
OS Version: 6.3
OS Arch: amd64
Java Version: 1.8.0_252
Java VM: OpenJDK 64-Bit Server VM
Java Vendor: AdoptOpenJDK
Java Home: c:\program files\dbvisualizer\jre
DbVis Home: C:\Program Files\DbVisualizer
User Home: -------
PrefsDir: -------
SessionId: 55
BindDir: -------
Product: DbVisualizer Pro 11.0.5 [Build #3113]
OS: Windows 10
OS Version: 10.0
OS Arch: amd64
Java Version: 1.8.0_252
Java VM: OpenJDK 64-Bit Server VM
Java Vendor: AdoptOpenJDK
Java Home: c:\program files\dbvisualizer\jre
DbVis Home: C:\Program Files\DbVisualizer
User Home: -------
PrefsDir: -------
SessionId: 968
BindDir: -------
有什么想法可以让程序显示真正的值,而不是 null 的解释值?
问题在 IBM support document 中解释:
Problem
Trying to insert a date value into a date column before 1940 or after 2039 will represent the date as NULL within the respective database table.
Cause
This is caused by a limitation with the IBM i database Toolbox JDBC driver as detailed in the related link:
How does the Toolbox JDBC driver deal with dates before 1940 (or after 2039)?
The IBM i database supports several date formats. The Toolbox JDBC driver uses the date format that is set up as the default on the IBM i system. This default is usually set to "mdy" which only supports dates between 1940 and 2039. You can override the date format by specifying the "date format" property when opening the JDBC connection. The best choice is "iso", which supports a full four-digit date. The easiest way to do this is to add ";date format=iso" to the end of the URL used when connecting to the database.
Resolving The Problem
Appending the ";date format=iso" to the host connection property for the applicable database
via Preferences-> EGL-> SQL Database Connections will then show the respective dates correctly eg:
1939-01-01.
可以通过执行以下操作在 DBVisualizer 中解决此问题:
- 数据库 -> 编辑数据库连接...
- Select 属性选项卡
- Select 驱动程序属性
- 将参数
date format
和 time format
编辑为 iso
- 应用更改
- 断开并重新连接
我在 DbVis 中发布了一个 SQL 语句:
select vestdate, name from person where vestdate is not null
并得到许多结果,其中 DbVisualizer 将授权日期显示为 (null)
!
经过调查,我发现授权日期是 '0001-01-01'
,因此查询正确返回了这些记录,但 DbVisualizer 显示 它们为 (null)
。
我刚刚从 windows 8 切换到 windows 10。
它适用于 windows 8(显示“0001-01-01”),但不适用于 windows 10(显示空):
Product: DbVisualizer Pro 11.0.4 [Build #3103]
OS: Windows 8.1
OS Version: 6.3
OS Arch: amd64
Java Version: 1.8.0_252
Java VM: OpenJDK 64-Bit Server VM
Java Vendor: AdoptOpenJDK
Java Home: c:\program files\dbvisualizer\jre
DbVis Home: C:\Program Files\DbVisualizer
User Home: -------
PrefsDir: -------
SessionId: 55
BindDir: -------
Product: DbVisualizer Pro 11.0.5 [Build #3113]
OS: Windows 10
OS Version: 10.0
OS Arch: amd64
Java Version: 1.8.0_252
Java VM: OpenJDK 64-Bit Server VM
Java Vendor: AdoptOpenJDK
Java Home: c:\program files\dbvisualizer\jre
DbVis Home: C:\Program Files\DbVisualizer
User Home: -------
PrefsDir: -------
SessionId: 968
BindDir: -------
有什么想法可以让程序显示真正的值,而不是 null 的解释值?
问题在 IBM support document 中解释:
Problem
Trying to insert a date value into a date column before 1940 or after 2039 will represent the date as NULL within the respective database table.
Cause
This is caused by a limitation with the IBM i database Toolbox JDBC driver as detailed in the related link:
How does the Toolbox JDBC driver deal with dates before 1940 (or after 2039)? The IBM i database supports several date formats. The Toolbox JDBC driver uses the date format that is set up as the default on the IBM i system. This default is usually set to "mdy" which only supports dates between 1940 and 2039. You can override the date format by specifying the "date format" property when opening the JDBC connection. The best choice is "iso", which supports a full four-digit date. The easiest way to do this is to add ";date format=iso" to the end of the URL used when connecting to the database.
Resolving The Problem
Appending the ";date format=iso" to the host connection property for the applicable database via Preferences-> EGL-> SQL Database Connections will then show the respective dates correctly eg:
1939-01-01.
可以通过执行以下操作在 DBVisualizer 中解决此问题:
- 数据库 -> 编辑数据库连接...
- Select 属性选项卡
- Select 驱动程序属性
- 将参数
date format
和time format
编辑为iso
- 应用更改
- 断开并重新连接