NutzCN Logo
问答 关于数据查询时空指针问题
发布于 47天前 作者 qq_152b6ff2 56 次浏览 复制 上一个帖子 下一个帖子
标签: ssdb

这是query代码。请问一下哪里出了问题
@At("/query")
public List demoSql(Dao dao){
Sql sql=Sqls.create("select * from test_bo where test1=a" );
sql.setCallback(new SqlCallback(){
public Object invoke(Connection conn,ResultSet rs,Sql sql)throws SQLException{
List list=new LinkedList();
while(rs.next())
list.add(rs.getString("test1"));
return list;
}
});
dao.execute(sql);
return sql.getList(String.class);
}


17-02-07 13:59:05.694 WARN [http-7001-1] Error@/test/query : java.lang.NullPointerException at nutztest.module.UserModule.demoSql(UserModule.java:65) at nutztest.module.UserModule$$FASTCLASS._invoke(UserModule.java:1) at org.nutz.lang.reflect.AbstractFastClass.invoke(AbstractFastClass.java:143) at org.nutz.lang.reflect.FastClassFactory.invoke(FastClassFactory.java:67) at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:27) 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.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:198) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454) at java.lang.Thread.run(Thread.java:619)
4 回复

Sql sql=Sqls.queryRecord("select * from test_bo where test1=a" );
dao().execute(sql);
List list = sql.getList(Record.class);
for(Record re :list){
.......
}

@swainho Record是用来做什么的呀

怎么把dao作为入口方法参数了?应该是实例变量

Record类用于非pojo方式访问数据库

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