0
@Override
public int getData(String username, String password) {
// TODO Auto-generated method stub
int Status = 1;
String sql = "select UserId from UserRegister where UserName=? and Password=? and Status=?;";
int userid = jdbcTemplate.queryForObject(sql, new Object[] { username,
password, Status }, Integer.class);
if (userid != 0) {
return userid;
} else {
userid = 0;
return userid;
}
}
例外を実行中に、誤った結果サイズ例外を取得:それはかもしれあなたを助けたら JDBC Spring MVCのログインに
org.springframework.web.util.NestedServletException: Request
processing failed; nested exception is
org.springframework.dao.EmptyResultDataAccessException: Incorrect
result size: expected 1, actual 0
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
javax.servlet.http.HttpServlet.service(HttpServlet.java:644)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
http://stackoverflow.com/questions/10606229/jdbctemplate-query-for-string-emptyresultdataaccessexception-incorrect-result –
を見てみましょうここでは、クエリと一緒にパラメータが整数値です。クエリと一緒にパラメータを渡す必要がある場合、私たちは何をしますか? – Joz