public List<Address> list(int userId) {
Address ad=null;
User us=null;
ResultSet rs=null;
List<Address> lt=null;
try {
String sql="select s_a.id a_id,s_a.name,s_a.phone,s_a.postcode,s_a.user_id,s_u.* from s_address s_a,s_user s_u where s_a.user_id=s_u.id and s_a.user_id=1";
lt=new ArrayList<Address>();
conn=DBUtil.getCon();
st=conn.createStatement();
rs=st.executeQuery(sql);
System.out.println(rs.next());
while(rs.next()){
us=new User(rs.getInt("id"),rs.getString("username"),rs.getString("password"),rs.getString("nickname"),rs.getInt("type"));
ad=new Address(rs.getInt("1"),rs.getString("name"),rs.getString("phone")
,rs.getString("postcode"),us);
lt.add(ad);
System.out.println(lt.size());
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("abc");
} finally{
DBUtil.close(null, st, conn);
}
return lt;
}
求解为何rs.next 返回的是false,sql语句在oracle中是可以查询到结果的啊
Address ad=null;
User us=null;
ResultSet rs=null;
List<Address> lt=null;
try {
String sql="select s_a.id a_id,s_a.name,s_a.phone,s_a.postcode,s_a.user_id,s_u.* from s_address s_a,s_user s_u where s_a.user_id=s_u.id and s_a.user_id=1";
lt=new ArrayList<Address>();
conn=DBUtil.getCon();
st=conn.createStatement();
rs=st.executeQuery(sql);
System.out.println(rs.next());
while(rs.next()){
us=new User(rs.getInt("id"),rs.getString("username"),rs.getString("password"),rs.getString("nickname"),rs.getInt("type"));
ad=new Address(rs.getInt("1"),rs.getString("name"),rs.getString("phone")
,rs.getString("postcode"),us);
lt.add(ad);
System.out.println(lt.size());
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("abc");
} finally{
DBUtil.close(null, st, conn);
}
return lt;
}
求解为何rs.next 返回的是false,sql语句在oracle中是可以查询到结果的啊










