db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bryan Pendleton (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DERBY-4375) WEME6.2 : Handful of test fixtures in InbetweenTest are failing with java.sql.SQLException: The syntax of the string representation of a datetime value is incorrect.
Date Fri, 18 Sep 2009 21:46:16 GMT

    [ https://issues.apache.org/jira/browse/DERBY-4375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12757460#action_12757460
] 

Bryan Pendleton commented on DERBY-4375:
----------------------------------------

Thank you Knut and Mamta for tracking this down and resolving it.

I was a little bit puzzled by the "11-30" part of the result, since as Knut
observes, Month=0,Day=0 should be the month and day before 1/1, which
in my mind is December 31, not November 30.

Indeed, when I wrote this little program:

Calendar c = Calendar.getInstance();
c.set(0, 0, 0, 12, 13, 14);
System.out.println(c.getTime());

It prints

Wed Dec 31 12:13:14 PST 0002

Which confirms Knut's understanding of the year 2 anomaly, and also computes
December 31 for Month=0,day=0, which is what I expected.

So I looked a little bit further and I see that when Timestamp.valueOf() parses
its string argument and constructs its timestamp, it internally uses the constructor
http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Timestamp.html#Timestamp%28int,%20int,%20int,%20int,%20int,%20int,%20int%29
which expects that day_of_month is numbered from 1-31 but month is numbered from 0-11,
so Timestamp.valueOf() subtracts 1 from the month, meaning that

Timestamp.valueOf("0000-00-00 15:47:28.0")); 

is actually analogous to the Calendar code:

c = Calendar.getInstance();
c.set(0, -1, 0, 12, 13, 14);
System.out.println(c.getTime());

and *that* code, inded, prints:

Sun Nov 30 12:13:14 PST 0002

All of this is a long and roundabout way of saying that I completely agree with everything
Mamta and Knut discovered, but wanted to post this anyway just in case anyone else
was wondering about the December 31 vs November 30 bit like I was. Here's my complete
program, for the curious:

import java.util.Calendar;
import java.sql.Timestamp;
public class Test
{
    public static void main(String []args)
    {
        System.out.println(Timestamp.valueOf("0000-00-00 15:47:28.0"));

        Calendar c = Calendar.getInstance();
        c.set(0, 0, 0, 12, 13, 14);
        System.out.println(c.getTime());

        c.set(0, -1, 0, 12, 13, 14);
        System.out.println(c.getTime());
    }
}

> WEME6.2 : Handful of test fixtures in InbetweenTest are failing with java.sql.SQLException:
The syntax of the string representation of a datetime value is incorrect.
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-4375
>                 URL: https://issues.apache.org/jira/browse/DERBY-4375
>             Project: Derby
>          Issue Type: Bug
>          Components: Test
>    Affects Versions: 10.6.0.0
>         Environment: weme 6.2 
>            Reporter: Mamta A. Satoor
>            Assignee: Mamta A. Satoor
>         Attachments: mamta.java, timeStampDiffValue.java
>
>
> On weme6.2, 8 test fixtures from InBetweenTest are failing with following error
> java.sql.SQLException: The syntax of the string representation of a datetime value is
incorrect.
> The failing test fixtures are 
> 1)testReproductionBeetle5135
> 2)testBeetle4316
> 3)testNestedQueries
> 4)testCheckQueries
> 5)testBigInList
> 6)testInBetween
> 7)testInList
> 8)testBetween
> The stack trace for testBetween looks as follows
> 1) testBetween(org.apache.derbyTesting.functionTests.tests.lang.InbetweenTest)java.sql.SQLException:
The syntax of the string representation of a datetime value is incorrect.
> 	at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
> 	at org.apache.derby.impl.jdbc.EmbedStatement.executeUpdate(Unknown Source)
> 	at org.apache.derbyTesting.functionTests.tests.lang.InbetweenTest.createTestObjects(InbetweenTest.java:195)
> 	at org.apache.derbyTesting.functionTests.tests.lang.InbetweenTest.testBetween(InbetweenTest.java:214)
> 	at java.lang.reflect.AccessibleObject.invokeV(AccessibleObject.java:195)
> 	at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:109)
> 	at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
> 	at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
> 	at junit.extensions.TestSetup.run(TestSetup.java:23)
> 	at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57)
> 	at junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
> 	at junit.extensions.TestSetup$1.protect(TestSetup.java:19)
> 	at junit.extensions.TestSetup.run(TestSetup.java:23)
> 	at org.apache.derbyTesting.junit.BaseTestSetup.run(BaseTestSetup.java:57)
> Caused by: ERROR 22007: The syntax of the string representation of a datetime value is
incorrect.
> 	at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
> 	at org.apache.derby.iapi.types.DateTimeParser.parseInt(Unknown Source)
> 	at org.apache.derby.iapi.types.SQLTimestamp.parseDateOrTimestamp(Unknown Source)
> 	at org.apache.derby.iapi.types.SQLTimestamp.parseTimestamp(Unknown Source)
> 	at org.apache.derby.iapi.types.SQLTimestamp.<init>(Unknown Source)
> 	at org.apache.derby.iapi.types.SQLChar.getTimestamp(Unknown Source)
> 	at org.apache.derby.iapi.types.SQLChar.getTimestamp(Unknown Source)
> 	at org.apache.derby.iapi.types.SQLTimestamp.setFrom(Unknown Source)
> 	at org.apache.derby.iapi.types.DataType.setValue(Unknown Source)
> 	at org.apache.derby.iapi.types.DataType.normalize(Unknown Source)
> 	at org.apache.derby.iapi.types.DataTypeDescriptor.normalize(Unknown Source)
> 	at org.apache.derby.impl.sql.execute.NormalizeResultSet.normalizeColumn(Unknown Source)
> 	at org.apache.derby.impl.sql.execute.NormalizeResultSet.normalizeRow(Unknown Source)
> 	at org.apache.derby.impl.sql.execute.NormalizeResultSet.getNextRowCore(Unknown Source)
> 	at org.apache.derby.impl.sql.execute.DMLWriteResultSet.getNextRowCore(Unknown Source)
> 	at org.apache.derby.impl.sql.execute.InsertResultSet.open(Unknown Source)
> 	at org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(Unknown Source)
> 	at org.apache.derby.impl.sql.GenericPreparedStatement.execute(Unknown Source)
> 	... 39 more
>  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message