NutzCN Logo
问答 执行自定义sql,明明有查询结果但就是娶不到
发布于 29天前 作者 蛋蛋的忧伤呀 88 次浏览 复制 上一个帖子 下一个帖子
标签:
Sql sql;
        Date now= HgUtils.getTodayStart();
//        now.set(Calendar.HOUR_OF_DAY,0);
//        now.set(Calendar.MINUTE,0);
//        now.set(Calendar.SECOND,0);


        if(fetch == null){
             sql = Sqls.create("SELECT COALESCE(SUM(o.total_price),0) as sum FROM orderinfo  o INNER JOIN User_Account  u ON o.`user_account` = u.`account` WHERE  o.parent = '0000' AND o.ostatus = '已完成'  AND o.`create_time` > '"+sdf.format(now.getTime())+"' AND o.`create_time` < '"+sdf.format(new Date())+"';");
             ok.setv("wallet","0");
//            sql.params().set("parent","0000");
//            return Result.fail().setv("admin",1);
        }else{
           sql  = Sqls.create("SELECT COALESCE(SUM(o.total_price),0) as sum FROM orderinfo  o INNER JOIN User_Account  u ON o.`user_account` = u.`account` WHERE  o.parent = '"+fetch.getPhone()+"' AND o.ostatus = '已完成' AND o.`create_time` > '"+sdf.format(now.getTime())+"' AND o.`create_time` < '"+sdf.format(new Date())+"' ;");
//            sql.params().set("parent",fetch.getPhone());
            ok.setv("wallet",fetch.getWallet());
        }
        final double[] todayMoney = new double[1];
        sql.setCallback(new SqlCallback() {
            public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
                if(rs.next()){
                    return rs.getDouble("sum");
                }
                return 0;
            }
        });
        dao.execute(sql);
//        int anInt = execute.getInt();
        ok.setv("todayMoney",sql.getDouble());//当日余额

执行的sql我复制到工具里执行了,是有值的,但就是取值的时候一直是0.0,我取得有问题吗?

6 回复

rs.next返回false了吧

我断点跟进,发现取出来一个0.0

连错数据库

没有.....这个真没可能,我就一个数据库连接....

好吧....是连错数据库了........

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