注册 登录
编程论坛 J2EE论坛

数据库小问题

新手上路了 发布于 2008-07-28 17:05, 882 次点击
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;
    }
这方法有什么问题?  调用类已测试正确
0 回复
1