Lew said:
This group puzzles me. On the one hand, there is a strong vocal
contingent stressing the importance of being portable between
databases. On the other hand, there is this advice to use the SQL DATE
type in a non-portable manner.
Which is better, to use DATE as the standard calls for it to be used,
holding only date information, or to take advantage of a DBMS-specific
extension to hold time information in violation of the standard and
portability?
Oracle is not following the standard.
Before 9i then DATE was the *only* option, because TIMESTAMP did
not exist.
If you have an existing table with DATE type, then it can very
likely contain hhmmss info.
I don't think it will be good practice to ignore that in a Java
app using that table just because the SQL standard type does not
contain hhmmss.
If you use java.sql.Timestamp, then the problem is that fractions of
seconds are lost when saving from Java to Oracle.
I consider that a much smaller problem.
If it is a new table, then it is easy just use TIMESTAMP and
no problem.
BTW a quick googling find that there are also some JDBC driver
issues to consider:
http://www.oracle.com/technology/tech/java/sqlj_jdbc/htdocs/jdbc_faq.htm#08_01
Portability is great. But the reality in SQL dialects is problems.
Arne