老师您好 这节课写完插入,查询就出现问题了
### Error querying database. Cause: org.apache.ibatis.executor.ExecutorException: No constructor found in com.damu.entity.Users matching [java.lang.Integer, java.lang.String, java.lang.String, java.lang.String, java.lang.Integer, java.lang.String, java.lang.String, java.lang.String, java.sql.Timestamp, java.sql.Timestamp, java.sql.Timestamp, java.lang.Integer, java.lang.String]
### The error may exist in mapper/usersMapper
### The error may involve com.damu.entity.Users.findUsers
### The error occurred while handling results
### SQL: SELECT * FROM users
### Cause: org.apache.ibatis.executor.ExecutorException: No constructor found in com.damu.entity.Users matching [java.lang.Integer, java.lang.String, java.lang.String, java.lang.String, java.lang.Integer, java.lang.String, java.lang.String, java.lang.String, java.sql.Timestamp, java.sql.Timestamp, java.sql.Timestamp, java.lang.Integer, java.lang.String]
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:150)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:136)
at com.damu.dao.UsersDao.findAll(UsersDao.java:27)
at com.damu.servlet.UsersFindServlet.doPost(UsersFindServlet.java:26)
at com.damu.servlet.UsersFindServlet.doGet(UsersFindServlet.java:21)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
null
package com.damu.entity;
import java.util.Date;
/**
* resource:mybatis-config.xml
* InputStream
* SqlSessionFactory
* SqlSession
* 执行我们配置好SQL语句
*/
public class Users {
private Integer id;//用户编号
private String name;//登录账号
private String userpass;//登录密码
private String nickname;//用户昵称
private Integer age;//用户年龄
private String gender;//用户性别
private String phone;//手机号
private String email;//用户邮箱
private Date createTime;//创建时间
private Date updateTime;//账号最后修改时间
private Date lastLogin;//用户的最后登录时间
private Integer userStatus;//用户账号状态 0 正常 1 锁定 2 删除
private String remark;//用户备注信息
public Users(Integer id, String name, String userpass, String nickname, Integer age, String gender, String phone, String email, Date createTime, Date updateTime, Date lastLogin, Integer userStatus, String remark) {
this.id = id;
this.name = name;
this.userpass = userpass;
this.nickname = nickname;
this.age = age;
this.gender = gender;
this.phone = phone;
this.email = email;
this.createTime = createTime;
this.updateTime = updateTime;
this.lastLogin = lastLogin;
this.userStatus = userStatus;
this.remark = remark;
}
public Users(String name, String userpass, String nickname, Integer age, String gender, String phone, String email, Date createTime, Date updateTime, Date lastLogin, Integer userStatus) {
this.name = name;
this.userpass = userpass;
this.nickname = nickname;
this.age = age;
this.gender = gender;
this.phone = phone;
this.email = email;
this.createTime = createTime;
this.updateTime = updateTime;
this.lastLogin = lastLogin;
this.userStatus = userStatus;
}
public Users(Integer id) {
this.id = id;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
/* public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}*/
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getUserpass() {
return userpass;
}
public void setUserpass(String userpass) {
this.userpass = userpass;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public Date getLastLogin() {
return lastLogin;
}
public void setLastLogin(Date lastLogin) {
this.lastLogin = lastLogin;
}
public Integer getUserStatus() {
return userStatus;
}
public void setUserStatus(Integer userStatus) {
this.userStatus = userStatus;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
@Override
public String toString() {
return "Users{" +
"id=" + id +
", name='" + name + '\'' +
", userpass='" + userpass + '\'' +
", nickname='" + nickname + '\'' +
", age=" + age +
", gender='" + gender + '\'' +
", phone='" + phone + '\'' +
", email='" + email + '\'' +
", createTime=" + createTime +
", updateTime=" + updateTime +
", lastLogin=" + lastLogin +
", userStatus=" + userStatus +
", remark='" + remark + '\'' +
'}';
}
}
package com.damu.dao;
import com.damu.entity.Users;
import com.damu.utils.SqlSessionFactoryUtils;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import java.util.List;
public class UsersDao {
//打开和数据库之间的会话
private SqlSession sqlSession ;
private List<Users> list;
private Users user;
private SqlSession getSqlSession(){
sqlSession = SqlSessionFactoryUtils.getSqlSessionFactory().openSession();
return sqlSession;
}
/**
* 查询全部用户
* @return
*/
public List<Users> findAll(){
try {
list = getSqlSession().selectList("findUsers");
} catch (Exception e) {
e.printStackTrace();
} finally {
sqlSession.close();
}
return list;
}
/**
* 根据ID查询用户
*/
public Users findById(Integer id){
try {
user = getSqlSession().selectOne("findUsers",new Users(id));
} catch (Exception e) {
e.printStackTrace();
} finally {
sqlSession.close();
}
return user;
}
/**
* 增加一个新用户数据到数据库的方法
*/
public Users addUser(Users user){
try {
//返回值:是insert执行过程中影响的行数
getSqlSession().insert("addUser",user);
sqlSession.commit();
} catch (Exception e) {
e.printStackTrace();
} finally {
sqlSession.close();
}
return user;
}
}
正在回答 回答被采纳积分+1
以解决 加了个无参构造方法
很好奇为什么没无参构造方法就报错,如果老师有时间讲解一下最好了 谢谢
相似问题
登录后可查看更多问答,登录/注册
- 参与学习 人
- 提交作业 357 份
- 解答问题 8016 个
本阶段将带你学习MySQL数据库,JDBC接口,MyBatis框架等,带你掌握的数据的存放和管理。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星