• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 583
  • 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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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