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

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

2013-11-23 20:48:42  來源: 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-2013 電腦知識網 Computer Knowledge   All rights reserved.