JAVA相关,while (super.rs.next()),总是进不了循环,求解,谢谢了
publicvoidprintPet(){super.open();Stringsql="selectid,name,agefromtests";try{super.ps...
public void printPet() {
super.open();
String sql = "select id,name,age from tests";
try {
super.pstmt = super.conn.prepareStatement(sql);
super.rs = super.pstmt.executeQuery();
System.out.println("编号\t名字\t年龄");
System.out.println("------------------------------");
while (super.rs.next()) {
System.out.println("wfwfwefwefwefw");
System.out.print(rs.getInt("id") + "\t");
System.out.print(rs.getString("name") + "\t");
System.out.println(rs.getInt("age") + "\t");
}
} catch (SQLException e) {
e.printStackTrace();
} 展开
super.open();
String sql = "select id,name,age from tests";
try {
super.pstmt = super.conn.prepareStatement(sql);
super.rs = super.pstmt.executeQuery();
System.out.println("编号\t名字\t年龄");
System.out.println("------------------------------");
while (super.rs.next()) {
System.out.println("wfwfwefwefwefw");
System.out.print(rs.getInt("id") + "\t");
System.out.print(rs.getString("name") + "\t");
System.out.println(rs.getInt("age") + "\t");
}
} catch (SQLException e) {
e.printStackTrace();
} 展开
2013-07-06
展开全部
看不到父类的代码,从这个片段较难推断。比如,你循环条件是super.rs,你的循环里面是rs,不知你的子类是否也定义了rs而隐藏了父类的rs,等等。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询