使用QueryRunner报错:java.sql.SQLException: Cannot create
程序员文章站
2022-06-15 09:11:05
...
在使用QueryRunner转换查询结果的时候:
QueryRunner qr = new QueryRunner();
List<Book> list = qr.query(sql, new BeanListHandler<Book>(Book.class));
报错
java.sql.SQLException: Cannot create Book
原因
没给Book类写无参构造函数
,加上之后就好了
创建的完整Book类
public class Book {
private int bid;
private String bname;
private float price;
private int category;
public Book() {
}
public int getBid() {
return bid;
}
public void setBid(int bid) {
this.bid = bid;
}
public String getBname() {
return bname;
}
public void setBname(String bname) {
this.bname = bname;
}
public float getPrice() {
return price;
}
public void setPrice(float price) {
this.price = price;
}
public int getCategory() {
return category;
}
public void setCategory(int category) {
this.category = category;
}
}
推荐阅读
-
SQL中使用sum()应该程序报错:java.math.BigDecimal cannot be cast to java.lang.Integer
-
el-tooltip组件中content使用Vue-i18n报错TypeError: Cannot read property ‘$t‘ of null
-
vue3 使用axios 会报错“Uncaught TypeError: Cannot read property ‘get‘ of undefined”
-
【案例分析】创建表报错误261: Cannot create file for table table-name.
-
使用webpack命令打包时,报错TypeError: Cannot read property 'presetToOptions' of undefined的解决办法
-
荐 nginx安装,make install报错: cannot create regular file启动报错find: “/lost+found”: 权限不够/opt/module/p
-
使用VectorDrawableCompat.create报错
-
antd 菜单组件 使用时报错:Cannot read property ‘isRootMenu‘ of undefined
-
java查询mysql时报“java.sql.SQLException:Cannot create ..(类名)”原因
-
使用QueryRuner出现java.sql.SQLException: Cannot create com.pojo.User:异常