Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / December 2005

Tip: Looking for answers? Try searching our database.

MySQL and Date Type columns with 2005-05-00 contents

Thread view: 
news@karsten-becker.de - 20 Dec 2005 13:42 GMT
Hi,
I'm currently trying to read a table from an MySQL database that has a
column of type Date which might contain entries like 2005-05-00.
Everything works as expected when it's used from PHP, but when I do an
getString on the resultSet, the Date Column gets converted to an Java
SQL Date type which does not accept such a Date field. And thus gives
me the result 2005-04-31. But what I really want is just the Date
Column as a STRING. I don't want it to get converted somewhere...
Btw, the 2005-05-00 should represent a Date where the Day is unknown or
not applicable. And I definitly need those cases...
Thanks for any hints in advance,
Karsten
Darko Topolsek - 20 Dec 2005 13:48 GMT
Hi Karsten,

if you just need date column as a String
why dont you declare date field in database like String ...

Warm Regards
Darko Topolsek
programmer
urbi et orbi

> Hi,
> I'm currently trying to read a table from an MySQL database that has a
[quoted text clipped - 8 lines]
> Thanks for any hints in advance,
> Karsten
news@karsten-becker.de - 20 Dec 2005 14:12 GMT
Darko Topolsek schrieb:

> Hi Karsten,
>
> if you just need date column as a String
> why dont you declare date field in database like String ...

Because performance would suck, and I just change them less frequently
then they get read. And as this tool should be quite independent from
the database structure, I don't have an influence on it..

Karsten

> Warm Regards
> Darko Topolsek
[quoted text clipped - 13 lines]
> > Thanks for any hints in advance,
> > Karsten
Silvio Bierman - 21 Dec 2005 00:01 GMT
> Hi,
> I'm currently trying to read a table from an MySQL database that has a
[quoted text clipped - 8 lines]
> Thanks for any hints in advance,
> Karsten

Sounds like a huge bug in MySQL that it allows you to store such a "date".
Although I can imagine some reasons why you might want this you simply
should not do this with a Date column in a relational database.

I suspect there will be few other DBMS systems that will let you get away
with this.

Silvio Bierman
Mark Matthews - 22 Dec 2005 15:28 GMT
>>Hi,
>>I'm currently trying to read a table from an MySQL database that has a
[quoted text clipped - 12 lines]
> Although I can imagine some reasons why you might want this you simply
> should not do this with a Date column in a relational database.

Silvio,

It's legacy (and explaining why would be a long rambling explanation of
what you can/can't do when you don't have transactions, which honestly
for some applications is just fine).

> I suspect there will be few other DBMS systems that will let you get away
> with this.

MySQL won't let you do it either if you start it with the
"NO_ZERO_IN_DATE" sql mode.

The JDBC driver itself will not create such dates, nor will it read them
by default, since Java has no way to represent a non-sensical date. It
sounds more like the other poster has a data model problem from the
start, in that he's using sentinel values to represent the concept of NULL.

    -Mark
Silvio Bierman - 22 Dec 2005 23:01 GMT
Hello Mark,

Legacy would be the only reason why such behaviour could exist. I would
prefer the default behaviour to be different though, one of the values of
using a RDBMS is the integrity checking at the data storage level.

Regards,

Silvio Bierman


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.