dbutils中的问题,大虾请帮忙看哈
public class BlogServlet extends HttpServlet {private static final long serialVersionUID = 1L;
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
String title=request.getParameter("title");
String content=request.getParameter("content");
String categoryId=request.getParameter("category");
System.out.println(title);
System.out.println(content);
System.out.println(categoryId);
int result=0;
Connection conn=SQLConnection.getConnection();
String sql= "insert into blog(title,content,category_id,create_time) values(?,?,?,getdate())";
try {
String[] params={title,content,categoryId};
QueryRunner qr=new QueryRunner();
result=qr.update(conn,sql,params);
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
String message="";
if(result==1){
message="添加博文成功!";
}else{
message="添加博文失败!";
}
request.setAttribute("message",message);
request.getRequestDispatcher("/addBlogResult.jsp").forward(request,response);
}
}
执行这句时出现错误: com.microsoft.sqlserver.jdbc.SQLServerException: 关键字 'SET' 附近有语法错误。 Query: insert into blog(title,content,category_id,create_time) values(?,?,?,getdate())
这是怎么回事啊?