Bug #70090 SQLException when getting a time value as 00:00:00
Submitted: 20 Aug 2013 12:02 Modified: 21 Aug 2013 6:58
Reporter: sara dominguez Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.1 OS:Windows
Assigned to: CPU Architecture:Any

[20 Aug 2013 12:02] sara dominguez
Description:
I´m getting this error when trying to get a time value previously stored in the database with the value 00:00:00. Note that this value is stored in a time type column (without any date):

 java.sql.SQLException: Value '00:00:00 can not be represented as java.sql.Time

For me this value is a valid time. Am I wrong?

The issue is that I have no problem at saving that value, but the error raises when I try to read the value from database.

If I just want to work with a time with no date (format HH:mm:ss), what´s the solution?

Thanks in advance

How to repeat:
First :Save in a time column in database the value 00:00:00. It works fine.
Second: Try to get the value through java connector
[20 Aug 2013 13:01] Bogdan Degtyariov
Hi Sara,

Thank you for your interest in MySQL Software.
I am a bit confused about this bug report because the category is set to "MySQL connector/C", but you are describing the issue in Connector/J.

So, I am changing the category.

What is the exact version of Connector/J 5.1 you are using?
[20 Aug 2013 13:24] Bogdan Degtyariov
Sara,

please check the following option:

zeroDateTimeBehavior: What should happen when the driver encounters DATETIME values that are composed entirely of zeros (used by MySQL to represent invalid dates)? Valid values are "exception", "round" and "convertToNull".

The default value is "exception". Try some other value like "round" or "convertToNull" depending on what serves your purpose better.
[20 Aug 2013 14:18] Peter Laursen
@Bogdan.

As user has already explained the datatype is a TIME - not a DATETIME.  And 00:00:00 is a valid TIME.
[20 Aug 2013 16:44] Sveta Smirnova
Thank you for the report.

Closed as "Not a Bug", because Bogdan's explanation.

Peter, this is Java type Time, not MySQL TIME.
[21 Aug 2013 6:58] sara dominguez
We've been researching the issue more in-depth and the exception is the following:
Caused by: java.sql.SQLException: java.sql.SQLException: Value '00:00:00 can not be represented as java.sql.Time
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
	at com.mysql.jdbc.ResultSet.getTimeFromBytes(ResultSet.java:6195)
	at com.mysql.jdbc.ResultSet.getTimeInternal(ResultSet.java:6227)
	at com.mysql.jdbc.ResultSet.getTime(ResultSet.java:5814)
	at com.mysql.jdbc.ResultSet.getTime(ResultSet.java:5849)
	at org.jboss.jca.adapters.jdbc.WrappedResultSet.getTime(WrappedResultSet.java:1422)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.6.0_22]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [rt.jar:1.6.0_22]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [rt.jar:1.6.0_22]
	at java.lang.reflect.Method.invoke(Method.java:597) [rt.jar:1.6.0_22]
	at org.hibernate.engine.jdbc.internal.proxy.AbstractResultSetProxyHandler.continueInvocation(AbstractResultSetProxyHandler.java:104) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
	... 158 more

Do you know which is the origin? Remember that in database the type is TIME and we access it with a java.sql.time type.

Thanks a lot