Reputation: 2177
i need a support,
i want to create product importer to woocommerce in Java.
One of column in "wp_posts" table is Timestamp type. But unfortunatelly if in wordpress i won't publicate a post/product, value of this field is "0000-00-00 00:00:00".
When my code try to cast the post to POJO Object, i have error:
java.sql.SQLException: Value '......' can not be represented as java.sql.Timestamp.
How should i cast "0000-00-00 00:00:00" to Timestamp in Java?
Upvotes: 0
Views: 192
Reputation: 640
Many DB Implemetations don't supported null in Timestamp column. So if you have 'null' in DB it may be represented as something like "0000-00-00 00:00:00". You can better use nullable Date column.
Upvotes: 0
Reputation: 2699
I believe this is caused by JDBC, add zeroDateTimeBehavior=convertToNull at the end of the jdbc connection string will fix. like this
jdbc:mysql://127.0.0.1:3306?zeroDateTimeBehavior=convertToNull
Refer: https://github.com/prestodb/presto/issues/2326
Upvotes: 2