Home >Database >Mysql Tutorial >mysql-java关于dbutils的使用

mysql-java关于dbutils的使用

WBOY
WBOYOriginal
2016-06-06 09:32:431149browse

mysqljavasejavadbutilssql

<code> /*     * 查找评论     */    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.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 (), 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;    }</comment></comment></comment></comment></code>

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn