当我输入数据在表单里面,就进行一次检查,ajax 将请求发送到服务器,与数据库核对,如果有了。则显示存在,否则显示可以使用。可是,当我无论输入什么都显示,可以试用。我发现在检查时,发现出错。希望各位可以指点下。万分感谢。
严重: Servlet.service() for servlet UserServlet threw exception
java.lang.NoClassDefFoundError: com/cn/db/DBConnection
at com.cn.mldn.impl.UserDAOProxy.(UserDAOProxy.java:16)
at com.cn.mldn.factory.DAOFactory.getUserDAOInstance(DAOFactory.java:18)
at com.cn.servlet.UserServlet.doPost(UserServlet.java:66)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
联系qq:369050897
public class UserDAOProxy implements IUserDAO {
private DBConnection dbc;
private IUserDAO userdao;
public UserDAOProxy() {
dbc = new DBConnection();/////调用这里发现出错 了。
this.userdao = new UserDAOImpl(dbc);//接口
}
public class DAOFactory {
public static IUserDAO getUserDAOInstance(){
return new UserDAOProxy();
}
}
public class UserDAOImpl implements IUserDAO{
private DBConnection dbc;
public UserDAOImpl(DBConnection dbc){
this.dbc=dbc;
}
public boolean checkUserId(String userid) throws Exception {
String sql="select * from user where userid=?";
PreparedStatement pstmt=this.dbc.getConnection().prepareStatement(sql);
pstmt.setString(1, userid);
ResultSet rs=null;
rs=pstmt.executeQuery();
return rs.next();
}