SQLException:无效的列名...? [英] SQLException: Invalid Column Name...?
问题描述
我有一个 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 之一中使用过完全相同的语句,它没有给我带来任何麻烦.此外,在项目的早期部署中不会出现此错误.我在一个不相关的变量中有一个错字,一旦它被修复,这个家伙就突然出现了.
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 表,请告诉我;任何帮助表示赞赏.
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屋!