Timestamp ending in zero in SQL results gets truncated
Opened this issue · 12 comments
When a timestamp is part of the SQL results and ends in a 0 (zero), the 0 is being truncated.
IDz customer reported the issue here -> https://l2l3-cmn-rtc.ratl.swg.usma.ibm.com:9443/ccm/web/projects/Rational%20Escalation#action=com.ibm.team.workitem.viewWorkItem&id=105487
IDz developer suspects the issue in the DSS library that IDz gets from DB2 team or maybe the DB2 driver jar.
Development environment where the bug occurred
-
Db2 Developer Extension version: v2.1.4
-
Editor platform
- Visual Studio Code
- Eclipse Theia
-
Editor platform version: IDz v16
-
Operating system on which your editor runs (for example, Windows 10 2004 or MacOS Catalina 10.15.7): Windows 10/11
-
Java Version (Run
java -version
and paste the details here): v11 -
Db2 for z/OS version (including function level for Db2 12): trying to get from customer, will update as soon as we get it
-
Log files attached?: No
When the SQL results contain a timestamp, and that timestamp ends in a zero, the zero is dropped from the display
Detailed steps for reproducing the problem:
Observed behavior
trailing zero is dropped
Expected behavior
trailing zero remains visible in output
Is somebody looking at this issue?
Is somebody looking at this issue?
Yes, we are looking into this issue.
Hello, is there any news? Please update ASAP.. Thx, Dante
Hello @Danuszek As you may know we're using JDBC to communicate with db2, JDBC returns timestamp without tailing 0. It's a JDBC limitation here.
ResultSet rs = stmt.executeQuery("select * from SC795701.TEST");
while (rs.next()) {
Timestamp ts = rs.getTimestamp(1);
System.out.println(ts);
String tss = rs.getString(1);
System.out.println(tss);
}
The timestamp I inserted was '2024-02-07-11.27.07.474600'. But I got below after executing the program.
2024-02-07 11:27:07.4746
2024-02-07 11:27:07.4746
Hello @equalchenbj , is it something we can change? If yes, who can change this behaviour?
personally, I wouldn't mind but one of our customers does. Hence, my question.
@Danuszek I can not find a way to change it.
ok
@equalchenbj , but why? Is it because you don't own the code?
@Danuszek JDBC driver development is not under Db2 mission/scope. So we will work with that team and open an issue for them to work it out.
We already discussed it with the JDBC driver team and they indicated that it is working as designed on their side.
The output is not truncated if:
- the JDBC property timestampPrecisionReporting =2
- and rs.getString() is used
The DB2 vscode extension uses rs.getDBTimeStamp() which will still truncate tailing 0
rs.getTimestamp : 2018-04-09 16:06:38.75813
rs.getString : 2018-04-09 16:06:38.758130
rs.getDBTimeStamp : 2018-04-09 16:06:38.75813
They said the DB2 vscode extension needs to be changed to use getString() instead.
So i'm not sure if the product should force a non-default 'timestampPrecisionReporting' setting on the JDBC connection, but seems worth looking at if using getString when fetching timestamp values instead of getTImestamp will let the user's potential setting of timestampPrecisionReporting =2 affect the response: