This post originated from an RSS feed registered with Java Buzz
by Marc Logemann.
Original Post: dont use SQL Date or use ORM
Feed Title: Logemann Blog
Feed URL: http://www.logemann.org/blojsom/blog/default/?flavor=rss2
Feed Description: Marc's thoughts on Java and more
Its amazing how many companies still write plain JDBC code and use advanced column types like Date. Its really a pain to make an application cross-database when you are in this mode. Either you end up writing case statements all over the time asking the connection what vendor it is, or you are trying to use JDBC escapes like "ts" or "d".
But then you will realize that even JDBC escapes are a pain, because if you want to supply a complete Date into a Date field, you will see that "d" doesnt catch it because its only the date, not the time. Then you will use "ts" and will be lucky that this works in Oracle. Now when you want to test your code using Derby for instance, you will notice that Derby doesnt convert "ts" to a Date column but only to a timestamp column. Of course you really dont want to create a different DDL for Derby than for your production DB.
This all boils down to DONT USE DATE AT ALL. Why not just using an integer holding a unix timestamp? And if you cant resist using Date. Then in gods name use an ORM layer.