MySQL JDBC Data Type

Source: Internet
Author: User

Reference: JDBC setobject non-mainstream performance report [1]

The time type in MySQL and Java corresponds

MySQL time type Time type corresponding to Java
Date Java. SQL. Date
Year Ava. SQL. Date
Datetime Java. SQL. Timestamp
Timestamp Java. SQL. Timestamp
Time Java. SQL. Time

Attached SectionCode

 
 calendar Cal = calendar. getinstance (); 
 timestamp now =  New  timestamp (Cal. gettime (). gettime (); 

preparestatement is used for JDBC insertion. settimestamp ()

besides, preparestatement has a bunch of setint, setstring, Setdate or something. In fact, there is also a very powerful stobject () that can automatically convert the matching type, and the performance is not bad, which extends a lot of usage, in fact, I just used to insert null-_-to the preparedstatement -_-! In addition, if you leave the placeholder in preparedstatement empty, it will be written as ** not specified **. I don't know if it will be automatically converted to null

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.