JackieShang
2016-10-10 09:24
public static void main(String[] args) throws Exception { GoddessDao g = new GoddessDao(); List<Goddess> gs = g.query(); for(Goddess goddess : gs){ System.out.println(goddess.getUser_name()+","+goddess.getAge()); } } public List<Goddess> query() throws Exception{ Connection conn=DBUtil.getConnection(); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("select user_name,age from imooc_goddess "); List<Goddess> gs =new ArrayList<Goddess>(); Goddess g = null; while(rs.next()){ g=new Goddess(); g.setAge(rs.getInt("age")); g.setUser_name(rs.getString("user_name")); gs.add(g); } return gs; }
建议打断点调试,看数据是什么时候不见的
JDBC之 “ 对岸的女孩看过来”
99324 学习 · 856 问题
相似问题