1
votes

I'm getting a MySQLSyntaxErrorException: Unknown column 'quantity' in 'field list' error when inserting value to my mysqldatabase. I have the column quantity in my table but it says unknown column in field list. Below is my code and I have no idea what's wrong with it. Can anyone help me? Thank you in advance.

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);

Adding the TABLE details to the question (taking it from the comment) for readability:

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
1
Please provide output of: describe tbl_reservations.eg04lt3r
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 NULLDaniel Nikko Bondoc
Do you use hibernate or maybe some other orm?eg04lt3r
i dont know what orm or hibernate means. sorry can u explain?Daniel Nikko Bondoc
the query runs and it inserts data to my table but its throwing that exception. i dont know whyDaniel Nikko Bondoc

1 Answers

0
votes

Hibernate Field Naming with Spring Boot

follow this guide : https://www.baeldung.com/hibernate-field-naming-spring-boot

with spring-boot-starter-data-jpa

If we create an entity call Account

@Entity
public class Account {
  @Id
  private Long id;
  private String defaultEmail;
}

Hibernate: create table account (id bigint not null, default_email varchar(255))

we don't need to specify the physical-strategy or the implicit-strategy properties in this case since we are accepting the defaults.