eskimo9
eskimo9

Reputation: 753

How to use Date and Time in JDBC with Oracle database

I have an Oracle database, and a Java program to access it through OJDBC. The sql DATE data type contains complete date and time information. The Java SQL libraries have 2 separate data types for Date and Time.

What's the easiest way to get around this whole stupid mess? Is it possible to write and read both time and date information from the SQL DATE type? Can I write a Timestamp to the database and have it save as a DATE type?

Upvotes: 1

Views: 5293

Answers (2)

Istvan Devai
Istvan Devai

Reputation: 4022

With version 9.2, use resultSet.getTimestamp, with version 11 JDBC driver, DATE should map automatically to the Timestamp java type.

Upvotes: 2

Scorpio
Scorpio

Reputation: 2327

We use the Timestamp-Database Type in Oracle with Joda DateTime and Hibernate. Works fine. This should work with classic jdbc as well. Check here

Upvotes: 1

Related Questions