Java.sql.SQLException:Value ' 0000-00-00 00:00:00 ' can not is represented as Java.sql.Date

Source: Internet
Author: User
Tags getdate

Schema use Jsp+servlet+java+mysql

The Time field type in MySQL is datetime

The field type in the Java entity class is date

Page, the Time field type is empty information is not displayed, and the error message is as follows:

Java.sql.SQLException:Value ' 0000-00-00 00:00:00 ' can not is represented as Java.sql.Dateat Com.mysql.jdbc.SQLError.createSQLException (sqlerror.java:1056) at Com.mysql.jdbc.SQLError.createSQLException ( sqlerror.java:957) at Com.mysql.jdbc.SQLError.createSQLException (sqlerror.java:927) at Com.mysql.jdbc.ResultSet.getDateFromBytes (resultset.java:2304) at Com.mysql.jdbc.ResultSet.getDate ( resultset.java:2052) at Com.mysql.jdbc.ResultSet.getDate (resultset.java:2015) at Com.mysql.jdbc.ResultSet.getDate ( resultset.java:2069) at Dao.impl.DevicesDaoImpl.findAll (devicesdaoimpl.java:26) at Service.impl.DevicesServiceImpl.findAll (devicesserviceimpl.java:20) at servlet. Deviceslist.doget (deviceslist.java:31) at Javax.servlet.http.HttpServlet.service (httpservlet.java:624) at Javax.servlet.http.HttpServlet.service (httpservlet.java:731) at Org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (applicationfilterchain.java:303) at Org.apache.catalina.core.ApplicationFilterChain.doFilter (Applicationfilterchain.java:208) at Org.apache.tomcat.websocket.server.WsFilter.doFilter (wsfilter.java:52) at Org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (applicationfilterchain.java:241) at Org.apache.catalina.core.ApplicationFilterChain.doFilter (applicationfilterchain.java:208) at filter. Encodingfilter.dofilter (encodingfilter.java:29)

Check the code, and did not find any problem, just because this data, this time field is empty, and the database in this field can be empty

Apparently, a lot of useless articles were searched. Also tried to change a lot. For example, on the JSP page <%=new SimpleDateFormat ("yyyy-hh-mm"). Format (Mobile.getmarkettime ())%>

The final error message is changed to this:

Java.lang.NullPointerExceptionat java.util.Calendar.setTime (Unknown Source) at Java.text.SimpleDateFormat.format ( Unknown source) at Java.text.SimpleDateFormat.format (Unknown source) at Java.text.DateFormat.format (Unknown source) at Org.apache.jsp.info_jsp._jspservice (info_jsp.java:200) at Org.apache.jasper.runtime.HttpJspBase.service ( HTTPJSPBASE.JAVA:70) at Javax.servlet.http.HttpServlet.service (httpservlet.java:731) at Org.apache.jasper.servlet.JspServletWrapper.service (jspservletwrapper.java:439) at Org.apache.jasper.servlet.JspServlet.serviceJspFile (jspservlet.java:395) at Org.apache.jasper.servlet.JspServlet.service (jspservlet.java:339) at Javax.servlet.http.HttpServlet.service ( httpservlet.java:731) at Org.apache.catalina.core.ApplicationFilterChain.internalDoFilter ( applicationfilterchain.java:303) at Org.apache.catalina.core.ApplicationFilterChain.doFilter ( applicationfilterchain.java:208) at Org.apache.tomcat.websocket.server.WsFilter.doFilter (wsfilter.java:52) at Org.apache.catalina.core.AppliCationfilterchain.internaldofilter (applicationfilterchain.java:241) at Org.apache.catalina.core.ApplicationFilterChain.doFilter (applicationfilterchain.java:208) at Org.apache.catalina.core.ApplicationDispatcher.invoke (applicationdispatcher.java:747) at Org.apache.catalina.core.ApplicationDispatcher.processRequest (applicationdispatcher.java:485) at Org.apache.catalina.core.ApplicationDispatcher.doForward (applicationdispatcher.java:410) at Org.apache.catalina.core.ApplicationDispatcher.forward (applicationdispatcher.java:337) at servlet. Deviceslist.doget (deviceslist.java:33)

Don't give up, keep looking.

http://blog.csdn.net/dczjzz/article/details/52446901 thank the author, help solve the problem, in addition to his mud and not dye, it must be done by himself

It's settled!

Java.sql.SQLException:Value ' 0000-00-00 00:00:00 ' can not is represented as Java.sql.Date

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.