desc = "Fishing Hooks";
code = "FH";
size = "#2";
cost = 2;
qnty = Integer.parseInt(hook2amount.getText());
amnt = qnty * cost;
Products h2 = new Products(desc,code,size,cost,qnty,amnt);
list.add(h2);
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "");
pst = con.prepareStatement("insert into purchase(username,code,desc,size,cost,quantity,date) values(?,?,?,?,?,?,?)");
pst.setString(1, user);
pst.setString(2, code);
pst.setString(3,desc);
pst.setString(4,size);
pst.setString(5, String.valueOf(cost));
pst.setString(6, String.valueOf(qnty));
pst.setString(7, date);
pst.executeUpdate();
} catch (Exception e) {
System.out.println("Error " + e);
}
I'm getting a syntax error saying
Error java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'desc,size,cost,quantity,date) values('sam','FH','Fishing Hooks','#2','2','2','7/' at line 1
I cant find my error