又是Null?
package com.fuyou.servlet;import java.io.IOException;import java.sql.ResultSet;import java.sql.SQLException;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import com.fuyou.util.DBConnection;import com.fuyou.util.mvconnection;public class loginservlet extends HttpServlet { private DBConnection dbc = new DBConnection(); private static final long serialVersionUID = -3265621922663327137L; public loginservlet() { } public void destroy() { super.destroy(); } public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String username = request.getParameter("username"); String password = request.getParameter("password"); String conformPswd = ""; String sql = "select * from user where username='" + username + "'"; ResultSet rs = null; mvconnection mvc = new mvconnection(); if (mvc != null) { rs = mvc.getResultSet(sql); } else { return; } if (rs != null) { try { if (rs.getString("password") != null) { conformPswd = rs.getString("PASSWORD"); } return; } catch (SQLException e) { e.printStackTrace(); } finally { this.dbc.closeResultSet(rs); } } if (password.equals(conformPswd)) { } } public void init() throws ServletException { }}
rs.hasNext()
[解决办法]
嘿嘿,没法了,换驱动吧。
[解决办法]
你的这段程序好像不怎么对:
if (rs != null) {
应当转换成:
if (rs != null && rs.hasNext() ) {
rs.next();
.....
[解决办法]
/* 验证方法 */
public boolean valieLogin(String userName,String passWord) {
boolean sucess = false;
Connection conn = null;
PreparedStatement pst = null;
ResultSet rs = null;
conn = DBConnection.getSQL();
try {
pst = conn
.prepareStatement("select * from user_login where userId=? and userPass=?");
pst.setString(1,userName);
pst.setString(2, passWord);
rs = pst.executeQuery();
if (rs.next()) {
sucess = true;
}
} catch (SQLException e) {
e.printStackTrace();
} finally {
try {
if (rs != null) {
rs.close();
rs = null;
}
if (pst != null) {
pst.close();
pst.close();
}
if (conn != null) {
conn.close();
conn = null;
}
} catch (SQLException e) {
e.printStackTrace();
}
}
return sucess;
}
[解决办法]
那应该是next了
ResultSet rs=s.executeQuery("select * from friends");
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html