关于DAO访问数据库的问题~) 将rs.next()循环出来的数据在放到set里面去不就可以了,但是set中不能有重复元素! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 从ResultSet里一个一个取出来,利用各字段构造成一个所需的对象,塞到Set里去。 贴一段你看看:Connection conn = null; try { System.out .println("DVBAppInfoFacadeDAOImpl#findAppInfoListByServiceRef serviceRef : " + serviceRef); conn = ds.getConnection(); PreparedStatement ps; Collection c = new ArrayList(); String query = "SELECT" + " A.id,A.component_tag,A.service_ref,P.id,A.application_type," + " A.descriptor_tag0x52,A.descriptor_data0x52,A.descriptor_tag0x6f," + " A.descriptor_data0x6f,A.rate" + " FROM dvb_ait_stream AS A,dvb_pid AS P" + " WHERE A.service_ref=?" + " AND A.pid_ref=P.id"; ps = conn.prepareStatement(query); ps.setInt(1, serviceRef); ResultSet rs = ps.executeQuery(); while (rs.next()) { DVBAppInfoData daid = new DVBAppInfoData(); daid.setId(new Integer(rs.getInt("id"))); daid.setComponentTag(new Integer(rs.getInt(2))); daid.setServiceRef(new Integer(rs.getInt(3))); daid.setPidRef(new Integer(rs.getInt(4))); daid.setApplicationType(new Integer(rs.getInt(5)).toString()); daid.setDescriptorTag0x52(rs.getBytes("descriptor_tag0x52")); daid.setDescriptorData0x52(rs.getBytes("descriptor_data0x52")); daid.setDescriptorTag0x6f(rs.getBytes("descriptor_tag0x6f")); daid.setDescriptorData0x6f(rs.getBytes("descriptor_data0x6f")); daid.setRate(new Integer(rs.getInt("rate"))); c.add(daid); } rs.close(); ps.close(); return c;.... ResultSet rs = sql.executeQuery();while (rs.next()){....}; 这样的定时器,如何实现? 问一个关于泛型的问题 jsp传值到action乱码 java连接池的问题 问一个非技术的问题,现在国内的培训市场还有很大的发展空间吗 求一个算法,1-99相加有几种可能等于100 用户 '(null)' 登录失败。未与信任 SQL Server 连接相关联 Struts登录验证问题,在线等,谢谢! 使用JbuilderX开发Struts的问题 applet 连接weblogic问题,急急急急! 有关ejb 怎样装载装载XML文件?
Connection conn = null;
try {
System.out
.println("DVBAppInfoFacadeDAOImpl#findAppInfoListByServiceRef serviceRef : "
+ serviceRef);
conn = ds.getConnection();
PreparedStatement ps;
Collection c = new ArrayList();
String query = "SELECT"
+ " A.id,A.component_tag,A.service_ref,P.id,A.application_type,"
+ " A.descriptor_tag0x52,A.descriptor_data0x52,A.descriptor_tag0x6f,"
+ " A.descriptor_data0x6f,A.rate"
+ " FROM dvb_ait_stream AS A,dvb_pid AS P"
+ " WHERE A.service_ref=?" + " AND A.pid_ref=P.id";
ps = conn.prepareStatement(query);
ps.setInt(1, serviceRef);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
DVBAppInfoData daid = new DVBAppInfoData();
daid.setId(new Integer(rs.getInt("id")));
daid.setComponentTag(new Integer(rs.getInt(2)));
daid.setServiceRef(new Integer(rs.getInt(3)));
daid.setPidRef(new Integer(rs.getInt(4)));
daid.setApplicationType(new Integer(rs.getInt(5)).toString());
daid.setDescriptorTag0x52(rs.getBytes("descriptor_tag0x52"));
daid.setDescriptorData0x52(rs.getBytes("descriptor_data0x52"));
daid.setDescriptorTag0x6f(rs.getBytes("descriptor_tag0x6f"));
daid.setDescriptorData0x6f(rs.getBytes("descriptor_data0x6f"));
daid.setRate(new Integer(rs.getInt("rate"))); c.add(daid); }
rs.close();
ps.close();
return c;
....
while (rs.next()){....};