熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> Java核心技術 >> 正文

用戶登錄的驗證完整程序

2013-11-23 19:11:40  來源: Java核心技術 

  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

  ClassforName(sunjdbcodbcJdbcOdbcDriver);

  Connection con = DriverManagergetConnection(jdbc:odbc:myDriver

  dbUserid dbPassword );

  Statement stmt = concreateStatement();

  String sql= select USERID from USERTABLE where USERID = +

  inputUserid + and PASSWORD = + inputPwd + ; ;

  ResultSet rs = stmtexecuteQuery(sql);

  if (rsnext())

  {

  returnString = rsgetString(USERID);

  }

  stmtclose();

  conclose();

  return returnString ;
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26419.html

    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.