Pregunta

The scenario:

I have a servlet that receives xmls, parses them (using JAXB), persists the parsed data to a MySQL DB (using hibernate) and also saves a copy of the xml for future reference. It saves this xml also when parsing fails. In these cases I receive an email with a summary of the error and then check the saved xml for clues to what went wrong.

The operation runs pretty smoothly. The servlet receives a couple of thousands xmls per day.

The problem:

At least once a day I get an error like this:

org.hibernate.exception.DataException: could not insert ..........
Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: '20122012-01-22 15:20:51' for column 'createdAt' at row 1

I get this error for some other "columns" as well. These columns are datetime type on mysql side and java.sql.Timestamp on the java side.

When I take a look at the xml that was received i see the correct date format: "2012-01-22 15:20:51"

Any idea what could have gone wrong?

¿Fue útil?

Solución

Haven't got this error lately. I've recently took care of a concurrency issue with SimpleDateFormat usage so maybe that was the problem.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top