在进行写入数据库时,objec变量赋值时的顺序应该和数据库value的数据一一对应,否则格式错误
String sql = "insert into topic(c_id, title, content, pv, user_id, username, user_img, create_time, update_time, hot, deleted) values(?,?,?,?,?,?,?,?,?,?,?)" ;
//objec里面的数据顺序应该和数据库value顺序一致。data in object should has the same order with the date in values, if not, we get an error which about the variable types
Object [] params = {
topic.getcId(),
topic.getTitle(),
topic.getContent(),
topic.getPv(),
topic.getUserId(),
topic.getUsername(),
topic.getUserImg(),
topic.getCreateTime(),
topic.getUpdateTime(),
topic.getHot(),
topic.getDeleted()
};