db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "A B (JIRA)" <derby-...@db.apache.org>
Subject [jira] Created: (DERBY-120) Date string returned from SELECT against Network Server is incorrect
Date Fri, 14 Jan 2005 23:07:18 GMT
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
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


Mime
View raw message