java.sql.SQLException: Cannot set billDate: incompatible types.

An error suddenly appeared when I was running the code.

The error information is as follows.

复制代码
Exception in thread "main" java.lang.RuntimeException: java.sql.SQLException: Cannot set billDate: incompatible types. Query: SELECT bill.*, NAME FROM bill, menu WHERE bill.menuId = menu.id Parameters: []
	at com.mhl.dao.BasicDAO.queryMulti(BasicDAO.java:56)
	at com.mhl.service.BillService.list2(BillService.java:53)
	at com.mhl.view.MHLView.listBill(MHLView.java:86)
	at com.mhl.view.MHLView.mainMenu(MHLView.java:247)
	at com.mhl.view.MHLView.main(MHLView.java:33)
Caused by: java.sql.SQLException: Cannot set billDate: incompatible types. Query: SELECT bill.*, NAME FROM bill, menu WHERE bill.menuId = menu.id Parameters: []
	at org.apache.commons.dbutils.QueryRunner.rethrow(QueryRunner.java:542)
	at org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:399)
	at com.mhl.dao.BasicDAO.queryMulti(BasicDAO.java:53)
	... 4 more

I went looking for a solution to the error, and in the process I discovered that the date-time type used when the table was created was datatime, whereas the type defined in the code was data.

Then I drop the table named bill, and create it again.

I then re-added the data and displayed the bill, this time successfully getting the result.

相关推荐
用户03321266636728 分钟前
Java 查找并替换 Excel 中的数据:详细教程
java
间彧29 分钟前
ThreadLocal实现原理与应用实践
java
若水不如远方36 分钟前
Netty的四种零拷贝机制:深入原理与实战指南
java·netty
用户74936368484341 分钟前
【开箱即用】一分钟使用java对接海外大模型gpt等对话模型,实现打字机效果
java
SimonKing1 小时前
一键开启!Spring Boot 的这些「魔法开关」@Enable*,你用对了吗?
java·后端·程序员
间彧2 小时前
Spring Boot集成Spring Security 6.x完整指南
java
xiezhr2 小时前
用户只需要知道「怎么办」,不需要知道「为什么炸了」
java·api·接口设计规范
xiezhr3 小时前
接口设计18条军规:写给那些半夜被“502”叫醒的人
java·api·restful
RainbowSea12 小时前
12. LangChain4j + 向量数据库操作详细说明
java·langchain·ai编程
RainbowSea12 小时前
11. LangChain4j + Tools(Function Calling)的使用详细说明
java·langchain·ai编程