A solution for the Java database to query fields of the date type with no hour, minute, and second, all 00

Source: Internet
Author: User
Solution to database query time out of minutes and seconds

The source of the problem: a company uses dynamic SQL to query the Oracle database in a project. When the Data Type field is displayed, only the date type field is displayed, and there is no time, minute, and second.

Analysis:

1. As we all know, there are many oralce date types, such as date and timestamp. The date type pair uses the java. SQL. date type, and the timestamp pair uses the java. SQL. timestamp type. Both types are inherited from Java. util. Date. java. SQL. date does not have time, minute, and second.

2. the GetObject (*) method of resultset returns java. SQL. date by default when the date type is used.

3. The solution provided by many people on the Internet is to change the database date type to the timestamp type, and the DBA of the database type will not allow you to change it, in Oracle, DBAs, which do not have strict requirements on time and minute/second, are recommended to use date instead of Timestamp to save resources.

4. The date type is specified as timestamp in the resultmap of ibatis, but it can be displayed normally.

After some consideration, we found that Rs. gettimestamp (*) can be used for date fields to be displayed normally.

Solution 2,

Add the Virtual Machine Parameters for servers and Java applications:-doracle. JDBC. v8compatible = "true"

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.