列名无效的问题!

海的童话 高级java工程师  2010-10-20 01:19:43
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 请高手指教下!
...全文
103 点赞 收藏 4
写回复
4 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
海的童话 2010-10-20
问题解决了 是因为有别的方法调用了PlatformTopoMapper 而downlinkids列 在另外的结果集中没有
回复
singlesteven 2010-10-20

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;
}

回复
海的童话 2010-10-20
方法没有错 上面都可以取的!
我换成按索引取 又报无效的列索引。。。。
bo.setDownlinkid(rowSet.getString(8));
回复
closewbq 2010-10-20
rowSet是个游标。你不next怎么能get获取呢?这个方法就写的不对
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2010-10-20 01:19
社区公告
暂无公告