jueves, 28 de enero de 2010

Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp

problem: Value '0000-00-00 00:00:00' can not be represented as java.sql.Timestamp

Razon/reason:

The MySQL Connector/J JDBC driver changed the way it handles DATETIME values in version 3.1. DATETIME values of all zeroes are considered illegal in versions 3.1 and above of MySQL Connector/J. Thus, an exception is thrown when these values are retrieved from a table.


Soluciones para esto:

The bug is fixed by adding the Configuration property "zeroDateTimeBehavior=convertToNull" to the JDBC URL generated by the Cloud Manager. For manually added connection user must add this property manually to the JDBC URL

esa es la "complicada" pero correcta, otra puede ser (puede) cacharlo en una excepcion, si tu conoces tu base de datos, sabes que en esa columna tiene un valor de fecha cero (zero date)


The other solution is just to catch it on a try-catch exception handler.

try {
fecha=miResultset.getString("fecha_visita").substring(0,10);
}
catch (Exception e) {
fecha="0000:00:00";
}

y voilà asunto arreglado, las fechas cero iguen en tu BD, pero eso ya lo sabes.

Si esto te sirvió por favor deja un comentario, aunque sea para saber que pasaste por aqui.
If this worked please leave a comment.

and please RTFM!

No hay comentarios:

Publicar un comentario