getpasswordaction.java
来自「采用web2.0技术,采用动态标签,sql语句全部存储在数据库里面.开发速度快.」· Java 代码 · 共 118 行
JAVA
118 行
package com.sztheater.biz.register;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;
import java.sql.*;
import java.util.*;
import com.sztheater.framework.web.*;
import com.sztheater.framework.util.*;
import java.util.*;
import javax.servlet.http.*;
public class GetPasswordAction extends Action {
protected int checkInfo (String username,HttpServletRequest request) {
String user = username;
int iSuccFlag = 0;
int iExistsNum =0;
String strMsg = "";
String strSQL = "";
HttpSession _httpSession= null;
ResultSet RSTemp = null;
Statement st = null;
Connection conn = null;
String f_name = null;
String f_value= null;
ArrayList fList = null;
ArrayList aList = null;
HashMap aHash = null;
int iRecCount = 0;
int iLoopNum = 0;
int iLoop = 0;
ValueObject sendPack = new ValueObject();
_httpSession = request.getSession();
try{
try{
conn = DbFunc.getConnection(false);
}catch(Exception e){
iSuccFlag = -90102;
if(conn!=null) DbFunc.free(conn,iSuccFlag);
conn = null;
strMsg = "服务取数据库连接异常"+e.getMessage();
System.out.println("strMsg"+strMsg);
}
//取得执行数据库操作Statement
st = conn.createStatement();
strSQL = "select * \n"
+ "from T_NetCustomer \n"
+ "where LoginName = '"+username+"'";
System.out.println("strSQLGetPasswordAction*="+strSQL);
// iRecNum = DbFunc.getRecordSet(-700034,"查询特定用户信息",conn, strSQL, 0, 0, aList);
//System.out.println("aList="+aList);
RSTemp = st.executeQuery( strSQL);
fList = DbFunc.getFields(RSTemp,false);
iLoopNum = 0;
if(fList!=null) iLoopNum = fList.size();
System.out.println("iLoopNum="+iLoopNum);
while (RSTemp != null && RSTemp.next()) {
for (iLoop=0;iLoop<iLoopNum;iLoop++){
f_name = (String)fList.get(iLoop);
f_value = RSTemp.getString(f_name);
if (f_name==null || f_value==null) continue;
if(aHash==null)aHash=new HashMap();
aHash.put(f_name,f_value);
}
}
request.setAttribute("userinfo",aHash);
System.out.println("aHash="+aHash);
}catch(Exception e){
CommFunc.freeObj(aList);
if(aList!=null) aList.clear();
strMsg = "发生异常\n" + e.getMessage();
System.out.println(strMsg);
System.out.println("SQL******************* \n"+strSQL );
}finally{
try{
if(RSTemp!=null) RSTemp.close();
}catch(Exception e1){
}
try{
if(st!=null) st.close();
if(conn!=null) conn.close();
}catch(Exception e1){
}
CommFunc.freeObj(fList);
if(fList!=null) fList.clear();
fList = null;
RSTemp= null;
}
return iRecCount;
}
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException,ServletException {
String target = new String("success");
String username = ((GetPasswordForm)form).getUsername();
checkInfo(username,request);
return (mapping.findForward(target));
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?