java关于dbutils的使用

 /*
     * 查找评论
     */
    public List<Comment> find(String blogID) {

        try {
            String sql = "select child.commentID,u.userName,child.commentContent,count(child.commentID) depth,child.commentParentID,child.commentTime from comment2 parent,comment2 child,user u where child.blogID = ? and child.blogID = parent.blogID and parent.left<=child.left and parent.right>=child.right and child.userID = u.userID group by child.commentID order by child.left";
            Object params[] = { blogID };
            List<Comment> list = qr.query(sql, new BeanListHandler<Comment>(
                    Comment.class), params);
             sql = "select u.userName from user u,comment c where c.commentID = ? and u.userID = c.userID";
            for (int i = 0; i < list.size(); i++) {
                if (list.get(i).getCommentParentID() != null) {
                    Object params1[] = { list.get(i).getCommentParentID() };
//                  String userName = qr.query(sql,new ScalarHandler<String>(), params1);
                    Comment commentParent = qr.query(sql, new BeanHandler<Comment>(Comment.class), params1);
                    System.out.println(sql+ commentParent.getUserName() );  
                    list.get(i).setCommentParent(commentParent);
                }
            }
            return list;
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return null;
    }

上面代码中,使用了dbutils这个工具,第一个sql语句能顺利查出结果,第二个sql语句什么都查不到,不管是用ScalarHandler还是beanHandler接收查到的数据都是空(userName和commentParent都为空),sql语句我在mysql试过了没问题能查出东西,param1[]里的东西也能正确传进去,可是就是查不出来,希望高手帮帮忙,帮我找找问题。

【配置数据源】
在tomcat的context.xml文件加入
<Resource name="jdbc/mysqlds" 
        auth="Container" 
        type="javax.sql.Dat......
答案就在这里:使用java的DBUtils
----------------------你好,人类,我是来自CSDN星球的问答机器人小C,以上是依据我对问题的理解给出的答案,如果解决了你的问题,望采纳。

在mysql处理时,?处的值,是你自己觉得的想象值,还是说,断点调试出来看到的传入params1的值?
按道理,不应该会查不出来的,如果说进不到BeanHandler里面,很有可能是数据库中表中的字段名,和你new 的实例对象的属性名不一致。

-------------------分隔线-----------------------------

你的代码太乱了,查起来太吃力了……我实在没有毅力看完

http://bbs.csdn.net/topics/391960499 去看看这个,最下面有我测试的结果

现在还用这个开发?????