2 nmszt55 nmszt55 于 2016.04.20 00:28 提问

使用DButils查询语句在DAO层报错Cannot Create Bean。。。query:。。。

报错信息:

java.sql.SQLException: Cannot create Bean.privilege: Bean.privilege Query: select p.* from privilege p,privilege_role pr where p.id=pr.p_id and pr.r_id=? Parameters: [007]
at org.apache.commons.dbutils.AbstractQueryRunner.rethrow(AbstractQueryRunner.java:392)
at org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:351)
at org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:180)
at dao.privilegeDao.getRoleprivileges(privilegeDao.java:80)
at service.BussinessService.getRolePrivileges(BussinessService.java:89)
at servlet.showRolePriUIServlet.doPost(showRolePriUIServlet.java:64)
at servlet.showRolePriUIServlet.doGet(showRolePriUIServlet.java:46)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at filter.CharacterFilter.doFilter(CharacterFilter.java:28)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at filter.RoleFilter.doFilter(RoleFilter.java:50)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)

at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2516)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2505)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

at java.lang.Thread.run(Thread.java:619)

DAO查询语句

    public List<privilege> getRoleprivileges(String Rid){
        try{
            QueryRunner qr = new QueryRunner();
            String sql = "select p.* from privilege p,privilege_role pr where p.id=pr.p_id and pr.r_id=? ";
            return (List<privilege>) qr.query(JDBCUtils.getconnection(),sql,Rid,new BeanListHandler<privilege>(privilege.class));
        }
        catch(Exception e){
            e.printStackTrace();
            throw new RuntimeException();
        }
    } 

privilegeBean

图片说明

6个回答

nmszt55
nmszt55   2016.04.20 00:36

补充,在数据库中创建了身份(role)数据库和一个(权限)数据库,还有2个库的连接数据库里面索引的身份和权限的id,想通过查询得到身份ID为XXX的包含的所有权限,但是查询过程中抛出500错误。求大神解答,

nmszt55
nmszt55   2016.04.20 00:36

使用的DbUtils框架,Handler为BeanListHandler。。。有没有对DBUtils熟悉的大手子

nmszt55
nmszt55   2016.04.20 00:38

没有C币了,能解决的大手子我给你支付宝上打点钱吧

fubo1990
fubo1990   2016.04.20 07:46

你没有privilege这个实体。或者映射文件。你可以把sql中的privilege改成privilegeBean试试

nmszt55
nmszt55 实体就是privilege,,,,Dbutils的映射就是DAO层写的BeanListHandler(privilege.class)但是就是取不出来。我在mysql中这条语句可以正常查询
一年多之前 回复
nmszt55
nmszt55   2016.04.20 14:12

问题解决!

把privilege改成了Privilege,就解决了,我也是醉了!!!!

fubo1990
fubo1990   2016.04.20 14:13

mysql 中是正常的。你按我的试试可以不?

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!