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

default java.util.Date parameters to setting timestamp rather than date #60

Merged
merged 1 commit into from Apr 3, 2014

Conversation

aldenquimby
Copy link
Contributor

Related to #59.

@aaberg please review/comment

@aaberg
Copy link
Owner

aaberg commented Apr 3, 2014

I think I tried something similar once, but it crashed when inserting a Date value into a date column on DB2.

I don't have a DB2 database available right now, but we could try to reproduce on other databases... I think the important detail was that the column datatype on the table was a date (with no time).

If we can't reproduce it on other databases, I will try if I can figure out how to setup a DB Express-C database. If this only occurs on DB2, we can use your code and add some special code for QuirksMode.DB2.

@aaberg
Copy link
Owner

aaberg commented Apr 3, 2014

Screw it!, I'll merge it and test it with our DB2 database at work!

aaberg added a commit that referenced this pull request Apr 3, 2014
default java.util.Date parameters to setting timestamp rather than date
@aaberg aaberg merged commit 7cf7cdf into master Apr 3, 2014
@aldenquimby aldenquimby deleted the date_default_timestamp branch April 3, 2014 19:21
@dimzon
Copy link
Contributor

dimzon commented Apr 9, 2014

@aldenquimby
@aaberg

sorry for necro-post but
AFAIK most DB differ Timestamp from DateTime that way (look @ min && max values i.e. range)
http://www.cubrid.org/manual/92/en/sql/datatype.html#date-time-types
http://dev.mysql.com/doc/refman/5.6/en/datetime.html
this maybe can produce strange behavior when you trying to write something like 01-07-1764
need to re-check

@aldenquimby
Copy link
Contributor Author

yes that date will fail in a TIMESTAMP column on most dbs. what are you proposing here? seems to me like that should be handled by a sql2o user, not in the lib itself

@dimzon
Copy link
Contributor

dimzon commented Apr 10, 2014

the problem is Java date type design flaws (in .NET there are simple DateTime type (TimeStamp represents interval, not the DateTime) and ADO.NET Providers works fine with them for all column types). this is why Calendar && JodaTime was created. This is why Java8 contains yet another DateTime API.

I think we can investigate problem a little. We need to write unit-test, passing 0001-01-01 AD && 9999-12-31 to PreparedStatement for DateTime columns to check using java.sql.Timestamp doesn't affect effective range...

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

Successfully merging this pull request may close these issues.

None yet

3 participants