public class IUserDao { public boolean find(String name,String password) throws Exception{ Connection conn = null; PreparedStatement st = null; ResultSet rs =null; try{ conn = DbUtils.getConn(); String sql = "select * from User where name=? and password=?"; st = conn.prepareStatement(sql); st.setString(1, name); st.setString(2, password); rs = st.executeQuery(); }catch (Exception e) { } System.out.println(rs); if(rs.next()){ System.out.println("没有记录"); return false; } else{ System.out.println("登录成功"); return true; } } public static void main(String args[]) throws Exception{ IUserDao ud=new IUserDao(); ud.find("admin", "12345d6"); } }其他类调用这个find 方法时,java.lang.NullPointerException at dao.IUserDao.find(IUserDao.java:36) ... ....
添加回答
举报
0/150
提交
取消