struts1中dynaactionform和Dao的问题
麻烦各位大哥给看看 我要实现的功能很简单 就是个登陆 可是到了DAO那地方 总是空指针
这是DAO文件
public class Dao {
Connection conn;
public Connection getConn() throws SQLException{
DriverManager.registerDriver(new OracleDriver());
String url="jdbc:oracle:thin:@localhost:1521:ORCL";
DriverManager.getConnection(url,"scott","tiger");
return conn;
}
public boolean Login(DynaActionForm showForm) throws SQLException{
conn=this.getConn();
PreparedStatement pstmt;
pstmt=conn.prepareStatement("select * from LX where ID=? and NAME=?");总显示这有问题
pstmt.setInt(1, Integer.parseInt( (String) showForm.get("ID")));
pstmt.setString(2, (String)showForm.get("NAME"));
ResultSet rs=pstmt.executeQuery();
if(rs.next()){
rs.close();
pstmt.close();
conn.close();
return true;
}
else{
rs.close();
pstmt.close();
conn.close();
return false;
}
}
}
这是Action文件
public ActionForward Login(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws SQLException {
DynaActionForm showForm = (DynaActionForm) form;// TODO Auto-generated method stub
Dao dao=new Dao();
if(dao.Login(showForm)){
return mapping.findForward("my");
}
else{
return mapping.findForward("you");
}
}