org.springframework.jdbc.BadSqlGrammarException: 高手解决
@Repository("userDao")@Scope("prototype")publicclassUserDaoImplextendsJdbcDaoSupporti...
@Repository("userDao")
@Scope("prototype")
publicclassUserDaoImpl extendsJdbcDaoSupport implementsUserDao {
@Resource
publicvoidsetmydata(DataSource dataSource) {
super.setDataSource(dataSource);// DataSource 连接池
}
publicvoiddelete(User user) throwsSQLException {
// TODO Auto-generated method stub
}
publicList<User> findAll() throwsSQLException {
String sql ="select * from user";
List<User> list=this.getJdbcTemplate().query(sql, newRowMapperUser());
returnlist;
}
publicUser findById(intid) throwsSQLException {
// TODO Auto-generated method stub
returnnull;
}
publicUser findByLoginName(String loginName) throwsSQLException {
// TODO Auto-generated method stub
returnnull;
}
//实体类
publicclassUser implementsjava.io.Serializable {
// Fields
privateInteger userId;
privateString userLoginName;
privateString userPassword;
privateString userName;
privateString userState;
privateString userPassengerType;
privateString userTelephone;
privateString userCertifType;
privateString userCertifNum;
privateString userEmail;
privateDate userCreationDate;
privateDate userLastLoginTime;
privateInteger userTotalLoginTimes = 0;
privateInteger userTotalLoginSeconds = 0;
privateString refPsgsId;
privateInteger refMembId;
}
//异常如下
org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [select * from user]; nested exception is java.sql.SQLException: Column ' user_certif_num' not found.
at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:97)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80) 展开
@Scope("prototype")
publicclassUserDaoImpl extendsJdbcDaoSupport implementsUserDao {
@Resource
publicvoidsetmydata(DataSource dataSource) {
super.setDataSource(dataSource);// DataSource 连接池
}
publicvoiddelete(User user) throwsSQLException {
// TODO Auto-generated method stub
}
publicList<User> findAll() throwsSQLException {
String sql ="select * from user";
List<User> list=this.getJdbcTemplate().query(sql, newRowMapperUser());
returnlist;
}
publicUser findById(intid) throwsSQLException {
// TODO Auto-generated method stub
returnnull;
}
publicUser findByLoginName(String loginName) throwsSQLException {
// TODO Auto-generated method stub
returnnull;
}
//实体类
publicclassUser implementsjava.io.Serializable {
// Fields
privateInteger userId;
privateString userLoginName;
privateString userPassword;
privateString userName;
privateString userState;
privateString userPassengerType;
privateString userTelephone;
privateString userCertifType;
privateString userCertifNum;
privateString userEmail;
privateDate userCreationDate;
privateDate userLastLoginTime;
privateInteger userTotalLoginTimes = 0;
privateInteger userTotalLoginSeconds = 0;
privateString refPsgsId;
privateInteger refMembId;
}
//异常如下
org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [select * from user]; nested exception is java.sql.SQLException: Column ' user_certif_num' not found.
at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:97)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80) 展开
1个回答
展开全部
Column ' user_certif_num' not found
追问
找到了,不过还是谢谢,是rs.getString("user_certif_num")多了一个空格
public class RowMapperUser implements RowMapper{
public Object mapRow(ResultSet rs, int index) throws SQLException {
user.setUserCertifNum(rs.getString("user_certif_num"));
}
}
追答
不谢,个人认为,多看看出错信息有好处,从显示的exception的来研究,祝你进步
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询