You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "dan meany (JIRA)" <de...@db.apache.org> on 2005/09/22 22:00:30 UTC
[jira] Commented: (DERBY-120) Date string returned from SELECT against Network Server is incorrect
[ http://issues.apache.org/jira/browse/DERBY-120?page=comments#action_12330225 ]
dan meany commented on DERBY-120:
---------------------------------
Using the 1.4.2 IBM VM I noticed it now formats like the Sun VM:
>java -version
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2)
Classic VM (build 1.4.2, J2RE 1.4.2 IBM z/OS Persistent Reusable VM build cm142-
20050623 (JIT enabled: jitc))
>cat Test.java
public class Test {
public static void main(String [] args) {
System.out.println(java.sql.Date.valueOf("0001-01-01"));
}
}
>javac Test.java
>java -classpath . Test
0001-01-01
Also I noticed that now using the Sun VM 1.4.2 for a Derby JDBC driver client and the IBM VM 1.4.2 for Derby NetworkServer, no error is produced.
> Date string returned from SELECT against Network Server is incorrect
> --------------------------------------------------------------------
>
> Key: DERBY-120
> URL: http://issues.apache.org/jira/browse/DERBY-120
> Project: Derby
> Type: Bug
> Components: Network Server
> Environment: Derby Network Server with IBM JRE
> Reporter: A B
>
> BACKGROUND:
> System.out.println(java.sql.Date.valueOf("0001-01-01"));
> With a Sun JVM, the above line will print "0001-01-01". With an IBM JVM, it will print "1-01-01". The difference is apparently in the implementation of the "toString()" method for the two JVMs.
> PROBLEM:
> Currently, when a query against Network Server returns a date column, the string value for that column is returned using the following line (in DRDAConnThread.java):
> writer.writeString(((java.sql.Date) val).toString());
> This works fine for Sun JVM, because the toString() method returns "0001-01-01". However, for IBM JVM, the string "1-01-01" is returned, and that causes the JDBC client to fail, presumably because the client sees it as an invalid date string.
> REPRODUCTION (with JDBC):
> Start the server with an IBM JVM, connect to it using ij, insert the value "0001-01-01" into a table, then select from the table. The repro here is for JDBC; a failure occurs for ODBC clients, as well.
> [ start server with IBM JRE and create a database ]
> ij> create table t1 (d date);
> 0 rows inserted/updated/deleted
> ij> insert into t1 values ('0001-01-01');
> 1 row inserted/updated/deleted
> ij> select * from t1;
> D
> ----------
> 699-07-22
> JAVA ERROR: java.lang.StringIndexOutOfBoundsException: String index out of range: 2941
> java.lang.StringIndexOutOfBoundsException: String index out of range: 2941
> at java.lang.String.checkBounds(String.java:646)
> at java.lang.String.<init>(String.java:678)
> at com.ibm.db2.jcc.a.d.a(d.java:819)
> [ ... ]
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira