将值插入mysqldatabase时出现MySQLSyntaxErrorException: Unknown column 'quantity' in 'field list'
错误。我在表格中有列数量,但在字段列表中显示未知列。下面是我的代码,我不知道它有什么问题。谁能帮我?提前谢谢。
query = "insert into tbl_reservations(cust_name,product_name,quantity,price,total,purchase_date,order_number,status) values ('" + nam + "','" + name[x] + "','" + quantity[x] + "','"+ fprice[x] + "','" + price[x] + "','" +currentDate+ "','" + rnum + "','" + status + "')";
System.out.println(query);
int i = st.executeUpdate(query);
System.out.println(query);
将TABLE详细信息添加到问题中(从评论中获取)以提高可读性:
Field Type Null Key Default Extra
id int(11) NO PRI NULL auto_increment
cust_name varchar(255) YES NULL
quantity int(11) YES NULL
price double NO NULL
total double NO NULL
purchase_date date YES NULL
order_number int(255) NO NULL
status varchar(255) NO NULL
答案 0 :(得分:0)
使用Spring Boot进行休眠字段命名
遵循本指南:https://www.baeldung.com/hibernate-field-naming-spring-boot
使用spring-boot-starter-data-jpa
如果我们创建实体电话帐户
@Entity
public class Account {
@Id
private Long id;
private String defaultEmail;
}
休眠:创建表帐户(id bigint不为null,default_email varchar(255))
在这种情况下,由于我们接受默认值,因此不需要指定物理策略或隐式策略属性。