Solved

howto catch SQL exception in jsp subroutine

Posted on 2011-09-08
4
567 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
  • 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

713 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