NutzCN Logo
问答 自定义sql查询日期的提示 HOUR_OF_DAY: 0 -> 1
发布于 122天前 作者 qq_0a7761ee 1285 次浏览 复制 上一个帖子 下一个帖子
标签:

数据库
``sql CREATE TABLEtest(idBIGINT NOT NULL AUTO_INCREMENT,birthdayDATE, PRIMARY KEY (id) ); INSERT INTOtest(birthday`) VALUES ( '1949-05-01');

自定义查询记录
   String sqlStr = "SELECT id, birthday FROM test";
    Sql sql = Sqls.queryRecord(sqlStr);
    dao.execute(sql);
    List<Record> list = sql.getList(Record.class);
    System.out.println(list);
错误内容

Exception in thread "main" org.nutz.dao.DaoException: Column Name=birthday, index=2
at org.nutz.dao.entity.Record.create(Record.java:76)
at org.nutz.dao.entity.Record.create(Record.java:38)
at org.nutz.dao.impl.sql.callback.QueryRecordCallback$1.createObject(QueryRecordCallback.java:18)
at org.nutz.dao.pager.ResultSetLooping.doLoop(ResultSetLooping.java:75)
at org.nutz.dao.impl.sql.callback.QueryRecordCallback.invoke(QueryRecordCallback.java:22)
at org.nutz.dao.impl.sql.NutSql.onAfter(NutSql.java:143)
at org.nutz.dao.impl.sql.run.NutDaoExecutor._runSelect(NutDaoExecutor.java:280)
at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:59)
at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:65)
at org.nutz.dao.impl.interceptor.DaoLogInterceptor.filter(DaoLogInterceptor.java:22)
at org.nutz.dao.DaoInterceptorChain.doChain(DaoInterceptorChain.java:63)
at org.nutz.dao.DaoInterceptorChain.invoke(DaoInterceptorChain.java:138)
at org.nutz.dao.impl.sql.run.NutDaoRunner.runCallback(NutDaoRunner.java:164)
at org.nutz.dao.impl.sql.run.NutDaoRunner._runWithoutTransaction(NutDaoRunner.java:131)
at org.nutz.dao.impl.sql.run.NutDaoRunner._run(NutDaoRunner.java:98)
at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:87)
at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:242)
at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:254)
at org.nutz.dao.impl.DaoSupport.execute(DaoSupport.java:238)
at org.nutz.dao.impl.NutDao.execute(NutDao.java:1291)
at com.qinyeit.tools.Application.main(Application.java:35)
Caused by: java.sql.SQLException: HOUR_OF_DAY: 0 -> 1
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:85)
at com.mysql.cj.jdbc.result.ResultSetImpl.getTimestamp(ResultSetImpl.java:1019)
at com.alibaba.druid.pool.DruidPooledResultSet.getTimestamp(DruidPooledResultSet.java:220)
at org.nutz.dao.entity.Record.create(Record.java:58)
... 20 more
Caused by: com.mysql.cj.exceptions.WrongArgumentException: HOUR_OF_DAY: 0 -> 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105)
at com.mysql.cj.result.SqlTimestampValueFactory.createFromTimestamp(SqlTimestampValueFactory.java:104)
at com.mysql.cj.result.SqlTimestampValueFactory.createFromDate(SqlTimestampValueFactory.java:73)
at com.mysql.cj.result.SqlTimestampValueFactory.createFromDate(SqlTimestampValueFactory.java:46)
at com.mysql.cj.result.BaseDecoratingValueFactory.createFromDate(BaseDecoratingValueFactory.java:53)
at com.mysql.cj.result.BaseDecoratingValueFactory.createFromDate(BaseDecoratingValueFactory.java:53)
at com.mysql.cj.protocol.a.MysqlTextValueDecoder.decodeDate(MysqlTextValueDecoder.java:72)
at com.mysql.cj.protocol.result.AbstractResultsetRow.decodeAndCreateReturnValue(AbstractResultsetRow.java:90)
at com.mysql.cj.protocol.result.AbstractResultsetRow.getValueFromBytes(AbstractResultsetRow.java:250)
at com.mysql.cj.protocol.a.result.ByteArrayRow.getValue(ByteArrayRow.java:91)
at com.mysql.cj.jdbc.result.ResultSetImpl.getNonStringValueFromRow(ResultSetImpl.java:656)
at com.mysql.cj.jdbc.result.ResultSetImpl.getDateOrTimestampValueFromRow(ResultSetImpl.java:679)
... 23 more
Caused by: java.lang.IllegalArgumentException: HOUR_OF_DAY: 0 -> 1
at java.util.GregorianCalendar.computeTime(GregorianCalendar.java:2829)
at java.util.Calendar.updateTime(Calendar.java:3395)
at java.util.Calendar.getTimeInMillis(Calendar.java:1782)
at com.mysql.cj.result.SqlTimestampValueFactory.createFromTimestamp(SqlTimestampValueFactory.java:100)
... 33 more

```

2 回复

这是时间戳有问题吧?

可以看看这篇文章,看看是不是时区的问题。
https://blog.csdn.net/SweetoRm/article/details/135696347

添加回复
请先登陆
回到顶部