用户登录的验证完整程序
2008-01-05 10:43:49 来源:WEB开发网核心提示:public String validateUser(String inputUserid, String inputPwd) throws SQLException{ String returnString = null; String dbUserid = "userid"; // Your D
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 ;
}
更多精彩
赞助商链接