sql = "select area ,count(mobile) as rowcounta from mmsendlog where 1=1";

解决方案 »

  1.   

    异常的具体内容是什么?
    1=1的条件在真实的SQL里什么样?删了试试
      

  2.   

    我捕获到的异常是:
    方法异常:java.sql.SQLException: 列名无效
    select area ,count(mobile) as rowcounta from mmsendlog where 1=1 and delivertime>='2009-08-07' and delivertime<='2009-08-07 24:60:60' group by area 
      

  3.   

    这是具体内容
                    
    sql = "select area ,count(mobile) as rowcounta from mmsendlog ";

    if(!area.equals("0"))
    {
    sql += " and area='"+ area + "'";
    }

    String startdate = safe.safeValue(request.getParameter("startdate"));
    request.getSession().setAttribute("startdate",startdate);

    if (!startdate.equals(""))
    {
    strListAction += "&startdate=" + startdate;//页面文件
    sql += " and delivertime>='" + startdate + "'";
    }
    String enddate = safe.safeValue(request.getParameter("enddate"));
    request.getSession().setAttribute("enddate",enddate);

    if (!enddate.equals(""))
    {
    strListAction += "&enddate=" + enddate;//页面文件
    sql += " and delivertime<='" + enddate + " 24:60:60'";
    }
    sql += " group by area";
    //数据库连接
    ConnectionDB con = new ConnectionDB();
    con.getConnection();//建立连接
    System.out.println(sql);
    ResultSet rs = con.executeQuery(sql);
      

  4.   

    我的意思是你把where都删了试试。。
      

  5.   

       基本语法错误! 简单的E文也要懂!group by
       
      

  6.   

    异常:java.sql.SQLException: 列名无效
    select area ,count(mobile) as rowcounta from mmsendlog group by area  这个是去掉where后的查询
      

  7.   

    基本语法错误! 简单的E文也要懂!group by  6 楼哥们说的是哪里错了 group by 没错啊
      

  8.   

    语句都是在sql窗口下面执行通过的。
      

  9.   

    select area ,count(mobile) as rowcounta from mmsendlog group by area
    还异常的话,我败了,楼主抱歉哈
      

  10.   

    我也很纳闷,所有语言在sql窗口里都可以查到结果,但是界面就抛异常。 
      

  11.   

    估计是在符号问题,设置断点在System.out.println(sql); 把sql的值 print 出来看一下!
      

  12.   

    select area ,count(mobile) as rowcounta from mmsendlog where 1=1 and delivertime>='2009-08-07' and delivertime<='2009-08-07 24:60:60' group by area select area ,count(mobile) as rowcounta from mmsendlog  group by areaselect area ,count(mobile) as rowcounta from mmsendlog where 1=1 group by area这都是打印出来的 并且在sql窗口里通过的
      

  13.   

    找到问题的所在了。
    select area ,count(mobile) as rowtotal from mmsendlog where 1=1
    下面这里的问题
     safe.safeHtmlValue(rs.getString("delivertime"));谢谢各位了