Re: Handling String date format "0000-00-00 00:00:00" removed in latest version???
Posted by: Mark Matthews
Date: February 18, 2005 08:39AM

Simon Haldon wrote:
> I recently tried upgrading to connector/J 3.1.6 -
> only to find this immediately broke my application
> wherever I was using zero dates in string format
> "0000-00-00 00:00:00".
>
> The connector/J changelog states that there are
> now three ways of handling zero dates, the default
> now being 'exception', and that other methods of
> handling can be specified in the server.xml
> connection url. This enabled me to correct the
> initial errors with zero dates.
>
> HOWEVER even if I change my server.xml, change all
> my zero dates to the supposedly valid "0001-01-01
> 01:01:01" (or "0001-01-01 00:00:00" I tried both)
> and change all (PreparedStatement) queries to
> reflect this, the MySql server dies a death as
> soon as I try to execute a query that references
> the date field
> (select ... where date='0001-01-01 01:01:01').
>
> The error (repeated - for each row in
> resultset?):
> ______________________________________
> Communications link failure due to underlying
> exception:
>
> ** BEGIN NESTED EXCEPTION **
>
> java.net.SocketException
> MESSAGE: Connection reset
>
> STACKTRACE:
>
> java.net.SocketException: Connection reset
> ______________________________________
>
> The errors occur identically on two installations
> - one running under Tomcat 5.0 and one Tomcat
> 5.5.7.
>
> I have reverted to connector/J 3.0.11 for now
> which works fine, but if anyone knows a way round
> this, it would help. I'm very surprised indeed
> that 3.1.6 is not backwards-compatible? - guess
> I'll be sticking with 3.0.11 unless something
> changes.


You should use 'zeroDatetimeBehavior=convertToNull' if you want the same behavior as Connector/J 3.0.x.

Unfortunately, all-zero dates are a bad thing, as far as JDBC is concerned, as there really is no way to represent them correctly in Java. Connector/J 3.1.x strives to be more JDBC compliant, and that includes not accepting data that would be handled in lossy or invalid ways. However, we do always add the ability to turn these features off (as you see).

-Mark

Mark Matthews
Consulting Member Technical Staff - MySQL Enterprise Tools
Oracle
http://www.mysql.com/products/enterprise/monitor.html

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.