db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "dan meany (JIRA)" <derby-...@db.apache.org>
Subject [jira] Commented: (DERBY-120) Date string returned from SELECT against Network Server is incorrect
Date Thu, 22 Sep 2005 20:00:30 GMT
    [ 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) {
>javac Test.java
>java -classpath . Test

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

>     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.
> 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.
> 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:
For more information on JIRA, see:

View raw message