NutzCN Logo
精华 自定义sql返回多条数据提示Invalid column or parameter name.
发布于 2870天前 作者 qq_ff330a3f 3228 次浏览 复制 上一个帖子 下一个帖子
标签: beyondb sql
String sql2 = "select description,resourceid from t_resource where resourceid in (select resourceid from t_resource_role where roleid = @roleId) order by resourceid ";
        Sql sqls = Sqls.create(sql2);
        sqls.params().set("roleId", 19);
        sqls.setCallback(new SqlCallback() {
            @Override
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                List<Record> list1 = new ArrayList<Record>();
                while (rs.next()) {
                    Record record = new Record();
                    record.put("roleCode", rs.getInt("rolecode"));
                    record.put("resourceDesp", rs.getString("description"));
                    list1.add(record);
                    data.add(record);
                }
                return list1;
            }
        });
        this.dao().execute(sqls);

代码如上,然后在执行到execute的时候,提示“java.sql.SQLException: Invalid column or parameter name.”
我把控制台输出的sql语句复制在数据库当中可以查询出结果。。。

8 回复

贴完整报错信息

@wendal

java.sql.SQLException: Invalid column or parameter name.
	at com.beyondb.gcf.util.SqlExType.getSqlEx(SqlExType.java:112)
	at com.beyondb.gcf.util.SqlExFactory.get(SqlExFactory.java:68)
	at com.beyondb.gcf.jdbc.JdbcRslt.columnByName(JdbcRslt.java:4673)
	at com.beyondb.gcf.jdbc.JdbcRslt.getInt(JdbcRslt.java:4414)
	at org.apache.commons.dbcp.DelegatingResultSet.getInt(DelegatingResultSet.java:275)
	at org.apache.commons.dbcp.DelegatingResultSet.getInt(DelegatingResultSet.java:275)
	at net.retror.bd.service.UserOpService$2.invoke(UserOpService.java:180)
	at org.nutz.dao.impl.sql.NutSql.onAfter(NutSql.java:134)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor._runSelect(NutDaoExecutor.java:233)
	at org.nutz.dao.impl.sql.run.NutDaoExecutor.exec(NutDaoExecutor.java:45)
	at org.nutz.dao.impl.DaoSupport$DaoExec.invoke(DaoSupport.java:327)
	at org.nutz.dao.impl.sql.run.NutDaoRunner.run(NutDaoRunner.java:59)
	at org.nutz.dao.impl.DaoSupport.run(DaoSupport.java:250)
	at org.nutz.dao.impl.DaoSupport._exec(DaoSupport.java:282)
	at org.nutz.dao.impl.DaoSupport.execute(DaoSupport.java:246)
	at org.nutz.dao.impl.NutDao.execute(NutDao.java:983)
	at net.retror.bd.service.UserOpService.getRolePermissionData(UserOpService.java:188)
	at net.retror.bd.module.UserModule.getRolePermissionData(UserModule.java:221)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:25)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:33)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.integration.shiro.NutShiroProcessor.process(NutShiroProcessor.java:126)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
	at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:196)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
	at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
	at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
	at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
	at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:217)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)

select 里有rolecode字段?

com.beyondb.gcf.jdbc.JdbcRslt.columnByName(JdbcRslt.java:4673)

这是啥库??? 里面报错了吧?

@wendal 这是我们公司自己开发的一套数据库,我也看不到里面的代码。。。。

你的sql里面就没有rolecode啊

record.put("roleCode", rs.getInt("rolecode"));

@wendal 哦,确实。。。。我错了。。。。。

……完全被忽略..

添加回复
请先登陆
回到顶部