列名无效的问题!

海的童话 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 请高手指教下!
...全文
212 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
海的童话 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获取呢?这个方法就写的不对

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧