简体   繁体   中英

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

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.

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.

EDIT: 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: Invalid column name ixPersonOpenedBy.

The mentioned column is not returned by SELECT .

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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