Java.sql.SQLException:Zero Date value Prohibited exception handling

Source: Internet
Author: User
Tags postgresql

The recent use of mybatis found the Java.sql.SQLException:Zero date value prohibited exception, the online check for a reason. In fact, the MySQL database in the face of 0000-00-00 00:00:00 date processing, if not set corresponding countermeasures, will produce an exception.

So the solution is to set up the processing Zerodatetimebehavior in Jdbcurl to deal with, generally have the following several:

1.driver-url=jdbc:mysql://127.0.0.1/test?zerodatetimebehavior=Converttonull

Zero date will be converted to null

2.driver-url=jdbc:mysql://127.0.0.1/test?zerodatetimebehavior=Round

Zero date will be converted to 0001-01-0100:00:00.0, equivalent to one year
In general, the use of converttonull will be better, to convert the date to null, more in line with the meaning of zero date



MySQL is one of the most popular open-source databases in the world. As a key component of the open-source software bundle LAMP (Linux, Apache, MySQL, and Perl/PHP/Python), MySQL has been widely applied to different scenarios.

Learn more about ApsaraDB RDS for MySQL - A fully hosted online database service that supports MySQL 5.5, 5.6, 5.7, and 8.0.





Alibaba Cloud Hot Products

Elastic Compute Service (ECS) Dedicated Host (DDH) ApsaraDB RDS for MySQL (RDS) ApsaraDB for PolarDB(PolarDB) AnalyticDB for PostgreSQL (ADB for PG)
AnalyticDB for MySQL(ADB for MySQL) Data Transmission Service (DTS) Server Load Balancer (SLB) Global Accelerator (GA) Cloud Enterprise Network (CEN)
Object Storage Service (OSS) Content Delivery Network (CDN) Short Message Service (SMS) Container Service for Kubernetes (ACK) Data Lake Analytics (DLA)

ApsaraDB for Redis (Redis)

ApsaraDB for MongoDB (MongoDB) NAT Gateway VPN Gateway Cloud Firewall
Anti-DDoS Web Application Firewall (WAF) Log Service DataWorks MaxCompute
Elastic MapReduce (EMR) Elasticsearch

Alibaba Cloud Free Trail

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.