Go Premium for a chance to win a PS4. Enter to Win

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 580
  • Last Modified:

howto catch SQL exception in jsp subroutine

I have the function shown below in a jsp program. When I try to  run the page I get the error:

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 255 in the jsp file: /printVouchers.jsp
sqe cannot be resolved

This very same code works fine as a function in a java program, What's wrong?

static boolean printDROPinfo(Connection con, JspWriter out, String memberId) throws Exception
    ResultSet rs = null;
    Statement stmt = con.createStatement();
    String query = "";

    query = "select ... from ... where ...";

    try {
        rs = stmt.executeQuery(query);
    catch ( SQLException sqe) {
      // do some things

   return true;
  • 2
2 Solutions
for the beginning try to change
catch ( SQLException sqe)


catch ( Exception sqe)

It probably would not help but could give some clue
maybe silly question but did you include the SQLException class in the jsp?
jmarkfoleyAuthor Commented:
Well, I just recoded the function from scratch and it works! The new code looks exactly like the code fragment I posted. Dunno, I must have messed up something. Thanks - points for the participation.
jmarkfoleyAuthor Commented:
recoded and worked. No idea why.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now