简体   繁体   English

SQLException:无效的列名...?

[英]SQLException: Invalid Column Name…?

I have a JSP file which I am deploying within a Java Project with the help of Eclipse, Maven, and Tomcat. 我有一个JSP文件,该文件将在Eclipse,Maven和Tomcat的帮助下部署在Java项目中。 I've got a few other JSP files almost identical to this one, though they run different operations. 我还有一些其他的JSP文件与此文件几乎相同,尽管它们运行不同的操作。 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 is a custom class that can take in a result set -- rsBug -- and performs the following operations: Bug是一个自定义类,可以接收结果集rsBug并执行以下操作:

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));

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. 其中BUG_ID,PERSON_OPENED_BY,PERSON_ASSIGNED_TO,TITLE和PROJECT_ID都是Bug类的所有字符串成员,它们与数据库中存储的Bug表中的列名相对应。 Now, there is a ixPersonOpenedBy column in the table, but it's never given me any problems before. 现在,表中有一个ixPersonOpenedBy列,但以前从未给我任何问题。 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. 我不确定它是否与我尝试执行的SQL语句有关,但是我之前在其他JSP之一中使用了EXACT相同的语句,并且没有给我带来任何麻烦。 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. 我在一个不相关的变量中有一个错字,一旦修正,这个家伙突然冒出来。

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; 如果您需要查看数据库中更多的JSP,Bug类或Bug表,请告诉我; any help is appreciated. 任何帮助表示赞赏。

EDIT: Here are the two SQL statements I'm using, but I'm not sure if either are causing the problem. 编辑:这是我正在使用的两个SQL语句,但我不确定是否其中一个引起了问题。

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: Invalid column name ixPersonOpenedBy. java.sql.SQLException:无效的列名ixPersonOpenedBy。

The mentioned column is not returned by SELECT . SELECT不会返回提到的列。

And indeed, none of your two SELECT queries specifies that column. 实际上,您的两个SELECT查询都没有指定该列。 Fix it accordingly. 相应地修复它。 Eg 例如

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM