Solved

howto catch SQL exception in jsp subroutine

Posted on 2011-09-08
4
569 Views
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
    }

    rs.close();
   return true;
}
0
Comment
Question by:jmarkfoley
[X]
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
4 Comments
 
LVL 47

Accepted Solution

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

to

catch ( Exception sqe)

It probably would not help but could give some clue
0
 
LVL 3

Assisted Solution

by:evedder
evedder earned 250 total points
ID: 36505494
maybe silly question but did you include the SQLException class in the jsp?
0
 
LVL 1

Author Comment

by:jmarkfoley
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.
0
 
LVL 1

Author Closing Comment

by:jmarkfoley
ID: 36507696
recoded and worked. No idea why.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What is this datetime? 1 33
Website checklist for browser compatibility? 2 57
Usage Scenarios for Extended Events - Tracking Recompilations 1 49
Java import explained 4 48
In this post we will learn different types of Android Layout and some basics of an Android App.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

734 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