初学者的问题..关于NullPointException..在线等--

notepads notepads 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
package test;
import java.sql.*;
import testbean.beantest;
public class test
{
private int pwdcheck(String name,String Pwd)
{
int flag=0;
String pass="";
ResultSet rs=null;
beantest checkPwd=new beantest();
String strsql="select UserPwd from login where UserId='"+name+"' or UserName='"+name+"'";
rs=checkPwd.GetRs(strsql);
try
{

while (rs.next())
{
pass=rs.getString("UserPwd");
}
rs.close();

if (pass.equals(Pwd))
flag=2;//密码正确
else
flag=3;//密码错误


}


catch (SQLException e)
{
flag=0;
}
return flag;
}



public int checklogin(String name,String Pwd){
ResultSet rs=null;
int count=0;
int flag=0;
beantest namecheck=new beantest();
String strsql="select count(*) as recount from login where UserId='"+name+"' or UserName='"+name+"'";
rs=namecheck.GetRs(strsql);
try{

while(rs.next())
{
count=rs.getInt("recount");
}


rs.close();
if(count==0)
flag=1;//用户存在
else{
if(pwdcheck(name,Pwd)==2)
flag=2;//密码正确
else
flag=3;//密码不正确
}



}
catch(SQLException e){return 0;}
return flag;
}



public static void main(String args[]){
test dd=new test();
System.out.println(dd.checklogin("ss","ss"));
}

}
----------------------运行结果-----------
Exception in thread "main" java.lang.NullPointException
at test.test.checklogin<test.java:50>
at test.test.checklogin<test.java:77>
----------------------------------------该怎么改啊,,困了两天了----
...全文

相关推荐

评论 11
收藏 已收藏
分享
返回顶部
notepads
Web 开发 81,108 成员 341,721 内容