public List getPlatformList(String pf){
String sql="select t4.deviceid,t4.devicetype,t4.devicename,t4.stationid,t4.xpoint,t4.ypoint,t4.platform,t5.downlinkid as downlinkids from t_platform_topo t4 left join (select t1.deviceid,t2.downlinkid from t_platform_topo t1 , t_node_display t2 ,t_station t3 "+
"where t1.stationid=t3.stationid and t2.station=t3.stationname and instr(t2.nodename,t1.devicename)>0 and  t1.platform ='"+pf+"' and t1.devicetype=3) t5 on  "+
        "t4.deviceid = t5.deviceid where t4.platform='"+pf+"'";
return getJdbcTemplate().query(sql, new PlatformTopoMapper());
}

class PlatformTopoMapper implements RowMapper{ public Object mapRow(ResultSet rowSet, int rowNum) throws SQLException {
final PlatformTopoBO bo = new PlatformTopoBO();
bo.setDeviceid(rowSet.getLong("deviceid"));
bo.setDevicename(rowSet.getString("devicename"));
bo.setDevicetype(rowSet.getInt("devicetype"));
bo.setPlatform(rowSet.getString("platform"));
bo.setStationid(rowSet.getInt("stationid"));
bo.setXpoint(rowSet.getInt("xpoint"));
bo.setYpoint(rowSet.getInt("ypoint"));
bo.setDownlinkid(rowSet.getString("downlinkids")); return bo;
}

}红色部分就是发出报错的地方! 数据库查没有问题  可能因为这个t5不是一个实际意义的表 所以不能识别downlinkid  请高手指教下!

解决方案 »

  1.   

    rowSet是个游标。你不next怎么能get获取呢?这个方法就写的不对
      

  2.   

    方法没有错  上面都可以取的!
    我换成按索引取  又报无效的列索引。
    bo.setDownlinkid(rowSet.getString(8));
      

  3.   


     public List<Card> queryCardByname(String sname) {
            Connection con = null;
            PreparedStatement ps = null;
            ResultSet rs = null;
            List<Card> list = new ArrayList<Card>();
            String sql = "select * from card where sname =?";
            con = db.getConnection();
            try {
                // System.out.println("!!!!!:"+rs.isClosed());
                ps = con.prepareStatement(sql);
                ps.setString(1, sname);
                rs = ps.executeQuery();
                while (rs.next()) {
                    Card cd = new Card();
                    cd.setSname(StringUtil.repairNull(rs.getString("Sname")));
                    cd.setCardfbid(StringUtil.repairNull(rs.getString("Cardfbid")));
                    list.add(cd);
                }
            } catch (SQLException ex) {
                ex.printStackTrace();
            } finally {
                this.close(ps, rs, con);
            }        return list;
        }
      

  4.   

    问题解决了 是因为有别的方法调用了PlatformTopoMapper   而downlinkids列 在另外的结果集中没有