sql语句的insert问题
private String time1;
private String content1;
private int post1;
private int user;
...........
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con=DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=bbs","cq","123");
stmt=con.createStatement();
String sql="insert into Reply(content,time,userId,postId) values('"+content1+"','"+time1+"',post1,user)";
stmt.execute(sql);
报错:
在此上下文中不允许使用名称 "post1"。有效表达式包括常量、常量表达式和变量(在某些上下文中)。不允许使用列名。
它不允许使用post1,我就改了数十种名字,都是不允许使用 不知道出什么问题了