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 ;
}
查看本文来源