它不是这样工作的吗?如何添加数据?
@Override
public void addArticle(Article article) {
//Add article
String sql = "INSERT INTO articles (articleId, title, category) values (?, ?, ?)";
jdbcTemplate.update(sql, article.getArticleId(), article.getTitle(), article.getCategory());
//Fetch article id
sql = "SELECT articleId FROM articles WHERE title = ? and category=?";
int articleId = jdbcTemplate.queryForObject(sql, Integer.class, article.getTitle(), article.getCategory());
//Set article id
article.setArticleId(articleId);
}