public
void
addForum(
final
Forum forum) {
final String sql = "INSERT INTO t_forum(forum_name, forum_desc) VALUES(?,?)";
KeyHolder keyHolder = new GeneratedKeyHolder();
getJdbcTemplate().update( new PreparedStatementCreator() {
public PreparedStatement createPreparedStatement(Connection conn) {
PreparedStatement ps = conn.prepareStatement(sql);
ps.setString(1, forum.getForumName());
ps.setString(2, forum.getForumDesc());
return ps;
}
}, keyHolder);
forum.setForumId(keyHolder.getKey().intValue());
}
final String sql = "INSERT INTO t_forum(forum_name, forum_desc) VALUES(?,?)";
KeyHolder keyHolder = new GeneratedKeyHolder();
getJdbcTemplate().update( new PreparedStatementCreator() {
public PreparedStatement createPreparedStatement(Connection conn) {
PreparedStatement ps = conn.prepareStatement(sql);
ps.setString(1, forum.getForumName());
ps.setString(2, forum.getForumDesc());
return ps;
}
}, keyHolder);
forum.setForumId(keyHolder.getKey().intValue());
}