gpt4 book ai didi

MySQL/JDBC/Hibernate 第 19 列中的 DATE '91' 格式错误

转载 作者:行者123 更新时间:2023-11-29 18:22:21 27 4
gpt4 key购买 nike

在模型中使用日期作为类型

@Column(name="birthdate")
private Date birtdate;

在 Spring Boot 应用程序中的模型用户中使用日期类型时出现以下异常

Hibernate: select user0_.user_id as user_id1_1_, user0_.address as address2_1_, user0_.alt_isd as alt_isd3_1_, user0_.alt_no as alt_no4_1_, user0_.approved as approved5_1_, user0_.birthdate as birthdat6_1_, user0_.blood_group as blood_gr7_1_, user0_.ckey as ckey8_1_, user0_.comp_name as comp_nam9_1_, user0_.created_date as created10_1_, user0_.ctime as ctime11_1_, user0_.driverunderuser as driveru12_1_, user0_.email as email13_1_, user0_.emergencycontact0 as emergen14_1_, user0_.emergencycontact1 as emergen15_1_, user0_.emergencycontact2 as emergen16_1_, user0_.image as image17_1_, user0_.interval_time as interva18_1_, user0_.isd_code as isd_cod19_1_, user0_.last_name as last_na20_1_, user0_.driver_license_no as driver_21_1_, user0_.license_expiry_date as license22_1_, user0_.mobile as mobile23_1_, user0_.modified_date as modifie24_1_, user0_.name as name25_1_, user0_.password as passwor26_1_, user0_.status as status27_1_, user0_.user_confirmation as user_co28_1_, user0_.user_type as user_ty29_1_, user0_.user_name as user_na30_1_ from tbl_user user0_ where user0_.user_name=?
2017-09-28 15:43:41.707 WARN 6844 --- [nio-8080-exec-6] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 0, SQLState: S1009
2017-09-28 15:43:41.707 ERROR 6844 --- [nio-8080-exec-6] o.h.engine.jdbc.spi.SqlExceptionHelper : `Bad format for DATE '91' in column 19.`
2017-09-28 15:43:41.719 ERROR 6844 --- [nio-8080-exec-6] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.orm.jpa.JpaSystemException: could not execute query; nested exception is org.hibernate.exception.GenericJDBCException: could not execute query] with root cause

java.sql.SQLException: Bad format for DATE '91' in column 19.
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:964) ~[mysql-connector-java-5.1.44.jar:5.1.44]

最佳答案

请尝试

@Column(name="birthdate")
@Temporal(TemporalType.DATE)
private Date birtdate;

参见What is the use of the @Temporal annotation in Hibernate?

关于MySQL/JDBC/Hibernate 第 19 列中的 DATE '91' 格式错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46466787/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com