MYSQLJDBC data type _ MySQL

Source: Internet
Author: User
MySQL JDBC data type Reference: non-mainstream performance report of JDBC setObject [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

Attach a piece of code

Calendar cal=Calendar.getInstance();
Timestamp now=new Timestamp(cal.getTime().getTime());

Then prepareStatement. setTimestamp () is used for JDBC insertion ()

Let's talk about prepareStatement. There are a bunch of setInt, setString, setDate and so on. 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.