为了账号安全,请及时绑定邮箱和手机立即绑定

老师麻烦你看下,他不会报数据库版本错误,要多大的才支持?????这个参数啊

package com.imooc.dao;

import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import com.imooc.model.Goddess;
import com.imooc.po.UDFtil;

public class GoddessDao {
	public void addGoddess(Goddess g) throws Exception{
		Connection conn=UDFtil.getConnection();
			String st="insert into imooc_goddess" +
					"(user_name,sex,age,birthday,email,mobil," +
					"create_user,create_date,update_user,update_date,isdel" +
					"values(" +
					"?,?,?,?,?,?,?,current_date(),?,current_date(),?)";
			PreparedStatement ptm=conn.prepareStatement(st);
			ptm.setString(1,g.getUser_name());
			ptm.setInt(2, g.getSex());
			ptm.setInt(3, g.getAge());
			ptm.setDate(4,new Date(g.getBirthday().getTime()));
			ptm.setString(5, g.getEmail());
			ptm.setString(6, g.getMobile());
			ptm.setString(7, g.getCreate_user());
			ptm.setString(8, g.getUpdate_user());
			ptm.setInt(9, g.getIsdel());
			ptm.execute();
	}
	public void updateGoddess(){
		
	}
	public void delGoddess(){
		
	}
	public List<Goddess> query() throws Exception{
		Connection conn=UDFtil.getConnection();
		//3.声明连接数据库,来操作数据库里面的数据
		 Statement st=conn.createStatement();
		 //4,通过statement里面的方法来进行数据操作
		 ResultSet rs=st.executeQuery("select user_name,age from imooc_goddess");
		 
		 List<Goddess> lg=new ArrayList<Goddess>();
		 Goddess g=null;
		 while(rs.next()){
			 g=new Goddess();
			 g.setUser_name(rs.getString("user_name"));
			 g.setAge(rs.getInt("age"));
			 
			 lg.add(g);
		 
		 }
		return lg;
	}
	public Goddess get(){
		return null;
	}
}


正在回答

3 回答

亲,这个就看慕课网的后续课程了,关于课程的任何意见建议,可以找官方人员联系。

iadljpjuwqhpgvtgrscemrrrehwravxsfbwammtgm

0 回复 有任何疑惑可以回复我~

我当时也报这个错,但是他不是版本错误

"?,?,?,?,?,?,?,current_date(),?,current_date(),?)";----有11个参数(2个是自动获取)

 ptm.setInt(9, g.getIsdel());-----传递9个参数,那么你在新增时    就需要设置这9个参数   

要不然  就会报错

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

老师麻烦你看下,他不会报数据库版本错误,要多大的才支持?????这个参数啊

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信