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

Struts從零開始三、連接數據庫實例[3]

2022-06-13   來源: Java開源技術 

String sql = select * from user where username= + username

  + and password= + userpass + ;

  try {

  Connection conn = dsgetConnection();

  Statement st = conncreateStatement();

  ResultSet rs = stexecuteQuery(sql);

  while (rsnext()) {

  flag = true;

  }

  } catch (Exception e) {

  eprintStackTrace();

  }

  String actionpath = ;

  if (flag) {

  requestsetAttribute(username username);

  actionpath = success;

  } else {

  actionpath = error;

  }

  return actionMappingfindForward(actionpath);

  }

  }

[]  []  []  []  


From:http://tw.wingwit.com/Article/program/Java/ky/201311/29128.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.