SQLException:列名无效......? [英] SQLException: Invalid Column Name...?

查看:123
本文介绍了SQLException:列名无效......?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JSP文件,我在Eclipse,Maven和Tomcat的帮助下在Java项目中部署。我有一些其他几乎与此相同的JSP文件,尽管它们运行不同的操作。无论如何,当我进入页面时,我已经给出了这个:

I have a JSP file which I am deploying within a Java Project with the help of Eclipse, Maven, and Tomcat. I've got a few other JSP files almost identical to this one, though they run different operations. Anyway, when I go to the page, I've given this:

org.apache.jasper.JasperException: An exception occurred processing JSP page /entertime2.jsp at line 106

103:    rsBug = psBug.executeQuery();
104:
105:    while(rsBug.next()) {
106:        Bug b = new Bug(rsBug);
107:        out.println("<option value='" + b.get(Bug.BUG_ID) + "'>" + b.get(Bug.TITLE) + "</option>");
108:    }
109:    rsBug.close();

root cause

javax.servlet.ServletException: java.sql.SQLException: Invalid column name ixPersonOpenedBy.

Bug是一个可以接收结果集的自定义类 - rsBug - 并执行以下操作:

Bug is a custom class that can take in a result set -- rsBug -- and performs the following operations:

setValue(Bug.BUG_ID,rs.getString(Bug.BUG_ID));
setValue(Bug.PERSON_OPENED_BY,rs.getString(Bug.PERSON_OPENED_BY));
setValue(Bug.PERSON_ASSIGNED_TO,rs.getString(Bug.PERSON_ASSIGNED_TO));
setValue(Bug.TITLE, rs.getString(Bug.TITLE));
setValue(Bug.PROJECT_ID,rs.getString(Bug.PROJECT_ID));

其中BUG_ID,PERSON_OPENED_BY,PERSON_ASSIGNED_TO,TITLE和PROJECT_ID都是Bug类的字符串成员到存储在数据库中的Bug表中的列名。现在,表格中有一个 ixPersonOpenedBy 列,但它之前从未给我任何问题。我不确定它是否与我尝试执行或不执行的SQL语句有任何关系,但我之前在其他JSP中使用了EXACT相同的语句,它没有给我任何麻烦。此外,在项目的早期部署中没有弹出此错误。我在一个不相关的变量中输入了一个拼写错误,一旦它被修复,这个人突然冒出来了。

Where BUG_ID, PERSON_OPENED_BY, PERSON_ASSIGNED_TO, TITLE, and PROJECT_ID are all string members of the Bug class that correspond to the column names within the Bug table stored in the database. Now, there is a ixPersonOpenedBy column in the table, but it's never given me any problems before. I'm not sure if it has anything to do with the SQL statement I try to execute or not, but I've used the EXACT same statement before in one of my other JSP's and it hasn't given me any trouble. In addition, this error wasn't popping up in earlier deployments of the project. I had a typo in an unrelated variable, and once it was fixed, this guy popped up outta nowhere.

无论如何,任何人都可以看到为什么当我出现这个错误时知道专栏应该有效吗?如果您需要查看更多JSP,Bug类或数据库中的Bug Table,请告诉我们;任何帮助都表示赞赏。

Anyway, can anyone see why this error would be given when I know the column "should" be valid? If you need to see more of the JSP, the Bug Class, or the Bug Table within the database, just let me know; any help is appreciated.

编辑:以下是我正在使用的两个SQL语句,但我不确定是否会导致问题。

Here are the two SQL statements I'm using, but I'm not sure if either are causing the problem.

SELECT p.ixPerson, p.sFullName 
FROM Person p, jwTeamMembers t 
WHERE p.ixPerson = t.ixPerson 
ORDER BY p.sFullName ASC


SELECT b.ixBug, b.sTitle 
FROM Bug b, Person per, Project p, Area a, jwTime t, jwTeamMembers m, jwTeam jt, Status s, jwDivision d
WHERE per.ixPerson = t.ixPerson AND t.ixBug = b.ixBug AND b.ixProject = p.ixProject AND b.ixArea = a.ixArea
    AND per.ixPerson = m.ixPerson AND m.ixTeam = jt.ixTeam AND b.ixStatus = s.ixStatus AND a.ixDivision *= d.ixDivision
    AND (per.ixPerson = ?)
GROUP BY b.ixBug, b.sTitle
ORDER BY b.ixBug DESC

参数在第二个语句中填充:

The parameter in the second statement is filled with:

psBug.setInt(1, Integer.valueOf(personId).intValue());


推荐答案


java.sql。 SQLException:列名无效ixPersonOpenedBy。

java.sql.SQLException: Invalid column name ixPersonOpenedBy.

SELECT 。

实际上,你的两个 SELECT 查询都没有指定该列。相应地修复它。例如

And indeed, none of your two SELECT queries specifies that column. Fix it accordingly. E.g.

SELECT b.ixBug, b.sTitle, b.ixPersonOpenedBy

这篇关于SQLException:列名无效......?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆