在表中查询department='hr'的记录,结果发现怎么也进不到while(rs.next)的循环中,con连接好了,数据库里有记录,查过了,找了个技术牛人来看了半天,郁闷地走了。
请大家卡看什么问题
代码如下:
public static ArrayList findSeniority(String department,DataSource ds) {
        System.out.println("------------------------------------"+department);
        Connection con = null;
        PreparedStatement ps = null;PreparedStatement ps1 = null;
        ResultSet rs = null;  ResultSet rs1 = null;
        
        Seniority seniority = null;
        ArrayList seniorityList = null;
        try {
            con = ds.getConnection();
            ps = con.prepareStatement(SENIORITY);
            ps.setString(1,department);
          //   ps.setString(1,"hr");
            rs = ps.executeQuery();
            seniorityList=new ArrayList();           
            while(rs.next()) {
                System.out.println("----------------i have come in---------------------");
                int empId = rs.getInt("employeeid");
                String name = rs.getString("employeename");
                String dept = rs.getString("department");
                int designationid = rs.getInt("designationid");
                int applicationid = rs.getInt("applicationid");
                String designation = null;
                String rating = null;
                
                //select designation from table hr_admin_designation
                ps1 = con.prepareStatement(DESIGNATION);
                ps1.setInt(1,designationid);
                 rs1 = ps1.executeQuery();
                if(rs1.next())
                {                     
                      designation = rs1.getString("designation_name");
                      ps1.close();rs1.close();
                }
              
              
                //select rating from table hr_admin_rating_form 
                ps1 = con.prepareStatement(RATING);
                ps1.setInt(1,applicationid);
                if(rs1.next())
                {
                    rs1 = ps1.executeQuery();
                    rating = rs1.getString("ratingid");
                    ps1.close();rs1.close();
                }
                
                
                seniority = new Seniority();
                seniority.setEmpId(empId);
                seniority.setName(name);
                seniority.setDepartment(dept);
                seniority.setDesignation(designation);
                seniority.setRating(rating);
                seniorityList.add(seniority);
                
                            }
            
        } catch (SQLException ex) {
            ex.printStackTrace();
        } finally{
            if(rs!=null){
                try {rs.close();
                } catch (SQLException ex) {
                    ex.printStackTrace();
                } }
            if(ps!=null)
                try {ps.close();
                } catch (SQLException ex) {
                    ex.printStackTrace();
                }
            if(con!=null)
                try {con.close();
                } catch (SQLException ex) {
                    ex.printStackTrace();
                }
        }
        return seniorityList;
    }

解决方案 »

  1.   

    ------------------------------------hr
    2008-9-20 14:41:11 org.apache.struts.tiles.TilesRequestProcessor initDefinitionsMapping
    信息: Tiles definition factory found for request processor ''.
    运行到这里就结束了
      

  2.   

    -_-
    你给的信息太少了,debug信息啥都没有看了等于白看,如果进不去while循环就表示你的rs是空的,用eclipse调试下就知道咯
      

  3.   

    ps = con.prepareStatement(SENIORITY); 这行中的”SENIORITY“是什么东西?怎么没看到???
      

  4.   

    SENIORITY="select * from hr_admin_employeeinf where department=?"
    rs.next()的值为false(),当用select * from hr_admin_employeeinf where department='hr'时,rs.next()的值是true
      

  5.   

    如果rs不为空的话,在while(rs.next()) 前加一句rs.first();试试,将指针移到第一个记录
      

  6.   

    问题出在了jdbc的驱动上,换了个oracle的新的驱动就可以了