首页 > 学院 > 开发设计 > 正文

用户登录的验证完整程序

2019-11-18 12:12:02
字体:
来源:转载
供稿:网友

public String validateUser(String inputUserid, String inputPwd)


throws SQLException{


String returnString = null;


String dbUserid = "userid"; // Your Database user id


String dbPassWord = "password" ; // Your Database password


Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");


Connection con = DriverManager.getConnection("jdbc:odbc:myDriver",


dbUserid ,dbPassword );


Statement stmt = con.createStatement();


String sql= "select USERID from USERTABLE where USERID = "" +


inputUserid + "" and PASSWORD = "" + inputPwd +"" ;" ;


ResultSet rs = stmt.executeQuery(sql);


if (rs.next())


{


returnString = rs.getString("USERID");


}


stmt.close();


con.close();


return returnString ;


}




发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表