亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

添加女神失敗

creat_user不知道?什么鬼。。在控制層不是設置女神的creat_user了么,然后傳給了模型層。求大神解答

com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown column 'create_user' in 'field list'
?? ?at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
?? ?at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
?? ?at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
?? ?at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
?? ?at com.mysql.jdbc.Connection.execSQL(Connection.java:3283)
?? ?at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1332)
?? ?at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:882)
?? ?at com.imooc.dbo.GoddessDao.addGoddess(GoddessDao.java:36)
?? ?at com.imooc.action.GoddessAction.add(GoddessAction.java:17)
?? ?at com.imooc.view.View.main(View.java:98)
新增女神失敗

view層的新增女神

?if(OPERATION_ADD.equals(in.toUpperCase())
?? ??? ??? ??? ??? ?||OPERATION_ADD.substring(0, 1).equals(in.toUpperCase())
?? ??? ??? ??? ??? ?||OPERATION_ADD.equals(prenious)){
?? ??? ??? ??? ?prenious=OPERATION_ADD;
?? ??? ??? ??? ?//新增女神
?? ??? ??? ??? ?
?? ??? ??? ??? ?if(1==step){
?? ??? ??? ??? ??? ?System.out.println("請輸入女神的[姓名]");
?? ??? ??? ??? ?}else if(2==step){
?? ??? ??? ??? ??? ?goddess.setUser_name(in);
?? ??? ??? ??? ??? ?System.out.println("請輸入女神的[年齡]");
?? ??? ??? ??? ?}else if(3==step){
?? ??? ??? ??? ??? ?goddess.setAge(Integer.valueOf(in));
?? ??? ??? ??? ??? ?System.out.println("請輸入女神的[生日],格式如:yyyy-MM-dd");
?? ??? ??? ??? ?}else if(4==step){
?? ??? ??? ??? ??? ?SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd");
?? ??? ??? ??? ??? ?Date birthday=null;
?? ??? ??? ??? ??? ?try {
?? ??? ??? ??? ??? ??? ?birthday = sf.parse(in);
?? ??? ??? ??? ??? ??? ?goddess.setBirthday(birthday);
?? ??? ??? ??? ??? ??? ?System.out.println("請輸入女神的[郵箱]");
?? ??? ??? ??? ??? ?} catch (ParseException e) {
?? ??? ??? ??? ??? ??? ?e.printStackTrace();
?? ??? ??? ??? ??? ??? ?System.out.println("您輸入的格式有誤,請重新輸入");
?? ??? ??? ??? ??? ??? ?step=3;
?? ??? ??? ??? ??? ?}
?? ??? ??? ??? ?}else if(5==step){
?? ??? ??? ??? ??? ?goddess.setEmail(in);
?? ??? ??? ??? ??? ?System.out.println("請輸入女神的[手機號]");
?? ??? ??? ??? ?}else if(6==step){
?? ??? ??? ??? ??? ?goddess.setMobile(in);
?? ??? ??? ??? ??? ?
?? ??? ??? ??? ??? ?try {
?? ??? ??? ??? ??? ??? ?action.add(goddess);
?? ??? ??? ??? ??? ??? ?System.out.println("新增女神成功");
?? ??? ??? ??? ??? ?} catch (Exception e) {
?? ??? ??? ??? ??? ??? ?e.printStackTrace();
?? ??? ??? ??? ??? ??? ?System.out.println("新增女神失敗");
?? ??? ??? ??? ??? ?}
?? ??? ??? ??? ?}

控制層Goddessaction的添加女神

public void add(Goddess goddess) throws SQLException{
?? ??? ?GoddessDao dao=new GoddessDao();
?? ??? ?goddess.setSex(1);
?? ??? ?goddess.setCreate_user("ADMIN");
?? ??? ?goddess.setUpdate_user("ADMIN");
?? ??? ?goddess.setIsdel(0);
?? ??? ?dao.addGoddess(goddess);
?? ?}
模型層GoddessDao的添加女神

public void addGoddess(Goddess g) throws SQLException{
?? ??? ?Connection conn=DBUtil.getConnection();
?? ??? ?String sql=" insert into imooc_goddess "+
?? ??? ??? ??? ??? ?" (user_name,sex,age,birthday,email,mobile, "+
?? ??? ??? ??? ??? ?" create_user,create_date,update_user,update_date,isdel) "+
?? ??? ??? ??? ??? ?" values( "+
?? ??? ??? ??? ??? ?" ?,?,?,?,?,?,?,current_date(),?,current_date(),?) ";
?? ??? ?PreparedStatement psmt = conn.prepareStatement(sql);
?? ??? ?psmt.setString(1, g.getUser_name());
?? ??? ?psmt.setInt(2, g.getSex());
?? ??? ?psmt.setInt(3, g.getAge());
?? ??? ?psmt.setDate(4, new Date(g.getBirthday().getTime()));
?? ??? ?psmt.setString(5, g.getEmail());
?? ??? ?psmt.setString(6, g.getMobile());
?? ??? ?psmt.setString(7, g.getCreate_user());
?? ??? ?psmt.setString(8, g.getUpdate_user());
?? ??? ?psmt.setInt(9, g.getIsdel());
?? ??? ?psmt.execute();
?? ?}

正在回答

舉報

0/150
提交
取消

添加女神失敗

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號