数据库小问题
public ArrayList getAllCatalogs() {ArrayList result = new ArrayList();
PreparedStatement ps = null;
try {
ps = (PreparedStatement)DbUtil.getConnection().createStatement();
ResultSet rs = (ResultSet) ps.executeQuery("select * from catalog");
while(rs.next()){
Catalog catalog = new Catalog();
catalog.setId(rs.getInt("id"));
catalog.setName(rs.getString("name"));
result.add(catalog);
} ps.close();
} catch (SQLException ex) {
Logger.getLogger(CatalogDaoImpl.class.getName()).log(Level.SEVERE, null, ex);
}
return result;
}
这方法有什么问题? 调用类已测试正确