Solved

howto catch SQL exception in jsp subroutine

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

705 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now