Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDBC 2.27 fails with year < 1000 #6468

Closed
monetdb-team opened this issue Nov 30, 2020 · 0 comments
Closed

JDBC 2.27 fails with year < 1000 #6468

monetdb-team opened this issue Nov 30, 2020 · 0 comments

Comments

@monetdb-team
Copy link

@monetdb-team monetdb-team commented Nov 30, 2020

Date: 2017-11-15 11:13:34 +0100
From: @swingbit
To: Martin van Dinther <<martin.van.dinther>>
Version: 11.23.13 (Jun2016-SP2)
CC: martin.van.dinther

Last updated: 2018-05-31 18:44:02 +0200

Comment 25877

Date: 2017-11-15 11:13:34 +0100
From: @swingbit

User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.62 Safari/537.36
Build Identifier:

JDBC 2.27:

Welcome to the MonetDB interactive JDBC terminal!
Database Server: MonetDB v11.27.10
JDBC Driver: MonetDB Native Driver v2.27 (Liberica 20171023 based on MCL v1.16)
Current Schema: spinque
Type \q to quit, \h for a list of available commands
auto commit mode: on
sql> select cast('0033-12-25' as date);
+------------+
| L2 |
+============+
|Error [22007]: Could not convert value to a Date. Expected JDBC date escape format yyyy-[m]m-[d]d. null
sql>

JDBC 2.26:

Welcome to the MonetDB interactive JDBC terminal!
Database Server: MonetDB v11.27.10
JDBC Driver: MonetDB Native Driver v2.26 (Liberica 20170728 based on MCL v1.15)
Current Schema: spinque
Type \q to quit, \h for a list of available commands
auto commit mode: on
sql> select cast('0033-12-25' as date);
+------------+
| L2 |
+============+
| 0033-12-25 |
+------------+
1 row
Elapsed Time: 11 ms
sql>

MCLIENT:

Welcome to mclient, the MonetDB/SQL interactive terminal (unreleased)
Database: MonetDB v11.27.10 (unreleased), 'mapi:monetdb://photon.hq.spinque.com:55500/x'
Type \q to quit, ? for a list of available commands
auto commit mode: on
sql>select cast('0033-12-25' as date);
+------------+
| L2 |
+============+
| 33-12-25 |
+------------+
1 tuple (1.157ms)
sql>

Reproducible: Always

Comment 25895

Date: 2017-11-16 17:01:32 +0100
From: Martin van Dinther <<martin.van.dinther>>

I couldn't reproduce this with the JdbcClient program.
I tested all versions of jdbcclient.jar from 2.27 back to 2.21.

However I know the error is thrown from method MonetResultSet.getDate(int, Calendar).

I could reproduce the problem with the JDBC driver (monetdb-jdbc-2.27.jar) used from SQuirreL (which uses getObject() which calls getDate() when the result column data type is date).

It appears that the standard java method
https://docs.oracle.com/javase/7/docs/api/java/sql/Date.htmlvalueOf(java.lang.String)
which convert a String to a Date object fails to do this for years which do not have 4 digits.
I will make a fix for this.

Comment 25898

Date: 2017-11-16 18:58:57 +0100
From: MonetDB Mercurial Repository <>

Changeset 95b48b249f68, made by Martin van Dinther martin.van.dinther@monetdbsolutions.com in the monetdb-java repo, refers to this bug.

For complete details, see https://dev.monetdb.org/hg/monetdb-java?cmd=changeset;node=95b48b249f68

Changeset description:

First fix for bug #6468
Works now for all years between 1 and 999, but not yet correct for negative years (-33 is shown as 0034).
ToDo: also make and include test program

Comment 26041

Date: 2017-12-21 13:03:14 +0100
From: Martin van Dinther <<martin.van.dinther>>

Completed fix and extended test program
https://dev.monetdb.org/hg/monetdb-java/rev/376a15ce49e3
https://dev.monetdb.org/hg/MonetDB/rev/b9bcb4267074

Comment 26472

Date: 2018-05-31 18:44:02 +0200
From: Martin van Dinther <<martin.van.dinther>>

A new version (2.28) of the MonetDB JDBC driver is released, see
https://www.monetdb.org/downloads/Java/
which includes the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant