1

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());
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Kris Schouw
  • 451
  • 4
  • 6
  • 13

1 Answers1

7

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. E.g.

SELECT b.ixBug, b.sTitle, b.ixPersonOpenedBy
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • It will now at least display the page after adding it. I'm just not sure why I had to add that column, especially since I don't even use it. – Kris Schouw Sep 12 '11 at 18:59
  • You're using it in constructor of `Bug` class. Perhaps you just need to remove that line if you don't even use it? :) By the way, your mapping approach is honestly said terrible and very 90's. Learn a bit about [Javabeans](http://stackoverflow.com/questions/1727603/places-where-javabeans-are-used) and about [avoiding Java code in JSP](http://stackoverflow.com/questions/3177733/how-to-avoid-java-code-in-jsp-files). To cream the top off, have a look at JPA to replace all that JDBC boilerplate. – BalusC Sep 12 '11 at 19:00
  • Yeah, I'm new to Java and web-based development. A lot of the code I'm using is modeled off of existing code that works. And I don't doubt that the code I've been looking at was first written in the 90's... – Kris Schouw Sep 12 '11 at 19:09
  • No problem. Just to let you know so that you're at least aware of that :) – BalusC Sep 12 '11 at 19:09