When the Oracle database saves dates in date type, which class in Java corresponds to the date type of the database?

Source: Internet
Author: User

1. When working with the Oracle database using JDBC, the date type of the database that corresponds to the java.sql.Date type is used, which can be saved and read only at this time.

Time (hours, minutes, seconds) can not be read and saved;

The query result set can get data of the Date type directly: Java.sql.Date date=resultset.getdate ("DateTime");

Data of the Java.sql.Date type can also be saved directly to the database or directly compared to the date type data in the database;

The date of the string, the conversion function to_date (' 2017-4-8 ', ' yyyy-mm-dd ') of the SQL statement to the date type is inserted into the database.

2. When using hibernate to operate an Oracle database, the Java.util.Date type corresponds to the date type of the database, at which time the database can be saved and read to seconds and minutes;

Data of the java.sql.Date and java.util.Date types can be saved directly to the database or directly compared to the date type data in the database, but the number

The date data that is read by the library is saved with Java.util.Date because Java.sql.Date is a subclass of Java.util.Date.

When the Oracle database saves dates in date type, which class in Java corresponds to the date type of the database?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.