Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


howto catch SQL exception in jsp subroutine

Posted on 2011-09-08
Medium Priority
Last Modified: 2012-05-12
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;
Question by:jmarkfoley
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 47

Accepted Solution

for_yan earned 1000 total points
ID: 36505320
for the beginning try to change
catch ( SQLException sqe)


catch ( Exception sqe)

It probably would not help but could give some clue

Assisted Solution

evedder earned 1000 total points
ID: 36505494
maybe silly question but did you include the SQLException class in the jsp?

Author Comment

ID: 36507690
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.

Author Closing Comment

ID: 36507696
recoded and worked. No idea why.

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question