public void addGoddess(Goddess goddess) throws SQLException { Connection connection = DBUtil.getConnection(); PreparedStatement preparedStatement = connection.prepareStatement( "insert into imooc_goddess(user_name, sex, age, birthday, email, mobile, " + "create_user, create_date, update_user, update_date, isdel) " + "values(?,?,?,?,?,?,?, now(), ?, current_date(), ?)"); preparedStatement.setString(1, goddess.getUser_name()); preparedStatement.setInt(2, goddess.getSex()); preparedStatement.setInt(3, goddess.getAge()); preparedStatement.setDate(4, new Date(goddess.getBirthday().getTime())); preparedStatement.setString(5, goddess.getEmail()); preparedStatement.setString(6, goddess.getMobile()); preparedStatement.setString(7, goddess.getCreate_user()); preparedStatement.setString(8, goddess.getUpdate_user()); preparedStatement.setInt(9, goddess.getIsDel()); preparedStatement.execute(); }
原文:https://www.cnblogs.com/yanguobin/p/12044024.html