照抄教师的,却提示两句出错,请大神帮忙
package com.test.action;
import java.util.Date;
import java.util.List;
import com.test.dao.GoddessDao;
import com.test.model.Goddess;
public class Goddessaction {
public static void main(String[] args) throws Exception {
GoddessDao g=new GoddessDao();
Goddess g1=new Goddess();
g1.setUser_name("小夏");
g1.setAge(20);
g1.setSex(1);
g1.setBirthday(new Date());
g1.setEmail("xiaoxia@163.com");
g1.setMobile("13566666666");
g1.setCreate_user("ADMIN");
g1.setUpdate_user("ADMIN");
g1.setId(1);
g.addgoddess(g1);//提示这句出错
List<Goddess> gs=g.query();
for (Goddess goddess : gs) {
System.out.println(goddess.getUser_name()+","+goddess.getAge());
}
}
}
-------------------------------------------------------------------------------------------------
package com.test.dao;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import com.test.db.DBUtil;
import com.test.model.Goddess;
public class GoddessDao {
public void addgoddess(Goddess g) throws Exception{
Connection conn=DBUtil.getconnection();
String sql = ""+"insert into dbtest_goddess"+
"(user_name,sex,age,birthday,email,mobile,create_user"+
"create_date,update_user,update_date,isdel)"+
"values(?,?,?,?,?,?,?,current_date(),?,current_date(),?)";
PreparedStatement ptmt=conn.prepareStatement(sql);
ptmt.setString(1,g.getUser_name());
ptmt.setInt(2,g.getSex());
ptmt.setInt(3,g.getAge());
ptmt.setDate(4,new Date(g.getBirthday().getTime()));
ptmt.setString(5,g.getEmail());
ptmt.setString(6,g.getMobile());
ptmt.setString(7,g.getCreate_user());
ptmt.setString(8,g.getUpdate_user());
ptmt.setInt(9,g.getIsdel());//提示这句出错
ptmt.execute();
}
public void updategoddess(){
}
public void delgoddess(){
}
public List<Goddess> query() throws Exception{
Connection conn=DBUtil.getconnection();
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("select user_name,age from dbtest_goddess");
List<Goddess> gs=new ArrayList<Goddess>();
Goddess g=null;
while(rs.next()){
g=new Goddess();
g.setUser_name(rs.getString("user_name"));
g.setAge(rs.getInt("age"));
gs.add(g);
}
return gs;
}
public Goddess get(){
return null;
}
}