oracle java.sql.SQLException: 列名无效 但在sql窗口可以通过,myEclipse 也不抛异常

JavaAlpha 2009-08-07 09:01:26
sql = "select area ,count(mobile) as rowcounta from mmsendlog where 1=1";
...全文
658 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
JavaAlpha 2009-08-07
  • 打赏
  • 举报
回复
找到问题的所在了。
select area ,count(mobile) as rowtotal from mmsendlog where 1=1
下面这里的问题
safe.safeHtmlValue(rs.getString("delivertime"));

谢谢各位了
JavaAlpha 2009-08-07
  • 打赏
  • 举报
回复
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 area

select area ,count(mobile) as rowcounta from mmsendlog where 1=1 group by area

这都是打印出来的 并且在sql窗口里通过的
cosio 2009-08-07
  • 打赏
  • 举报
回复
估计是在符号问题,设置断点在System.out.println(sql); 把sql的值 print 出来看一下!
JavaAlpha 2009-08-07
  • 打赏
  • 举报
回复
我也很纳闷,所有语言在sql窗口里都可以查到结果,但是界面就抛异常。
fatfoxz 2009-08-07
  • 打赏
  • 举报
回复
select area ,count(mobile) as rowcounta from mmsendlog group by area
还异常的话,我败了,楼主抱歉哈。。。
JavaAlpha 2009-08-07
  • 打赏
  • 举报
回复
语句都是在sql窗口下面执行通过的。
fatfoxz 2009-08-07
  • 打赏
  • 举报
回复
我认为是单引号的问题。。。
可能需要两个单引号来表示一个单引号
JavaAlpha 2009-08-07
  • 打赏
  • 举报
回复
基本语法错误! 简单的E文也要懂!group by 6 楼哥们说的是哪里错了 group by 没错啊
JavaAlpha 2009-08-07
  • 打赏
  • 举报
回复
异常:java.sql.SQLException: 列名无效
select area ,count(mobile) as rowcounta from mmsendlog group by area

这个是去掉where后的查询
多壮志 2009-08-07
  • 打赏
  • 举报
回复
基本语法错误! 简单的E文也要懂!group by
fatfoxz 2009-08-07
  • 打赏
  • 举报
回复
我的意思是你把where都删了试试。。。。。
JavaAlpha 2009-08-07
  • 打赏
  • 举报
回复
这是具体内容

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);
JavaAlpha 2009-08-07
  • 打赏
  • 举报
回复
把 1=1 删了也是一样不行
JavaAlpha 2009-08-07
  • 打赏
  • 举报
回复
我捕获到的异常是:
方法异常: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
fatfoxz 2009-08-07
  • 打赏
  • 举报
回复
异常的具体内容是什么?
1=1的条件在真实的SQL里什么样?删了试试

17,086

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧