Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8504363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:00:33+00:00 2026-06-11T02:00:33+00:00

My struts2 webapp makes use of a SQL database. Within the DB access code,

  • 0

My struts2 webapp makes use of a SQL database. Within the DB access code, I’ve written a basic try/catch handler that catches SQL or general exceptions, writes the detail to a log file, and then continues. The hierarchy of classes is as follows:

Action method -> get or set method on Model -> DB access.

//Action method in action class
public string doActionMethod() throws Exception
{
    String results = SampleModel.getResults();
}

//Model method in model class
public string getResults() throws Exception
{
    String results = DBLayer.runQuery("SELECT Results FROM SampleTable WHERE Value='1');
}

//Method that queries database in DB access class
public string runQuery() throws Exception
{
    ResultSet rs = null;
    Connection dbConnection = null;
    PreparedStatement preparedStatement = null;     

    dbConnection = MSSQLConnection.getConnection();

    preparedStatement = dbConnection.prepareStatement(sqlQuery);

    //run SQL statements

    return String(rs.get(0));
}

I’d like caught exceptions to bubble up to the Action level, so that I can forward them to an appropriate error page. Is there a better way to do this than adding a “throws Exception” to the method signature?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T02:00:35+00:00Added an answer on June 11, 2026 at 2:00 am

    Since you have no hope of recovery, throw an application-specific RuntimeException.

    Use standard Struts 2 declarative exception handling to get your app to the appropriate error page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a basic Struts2, Maven webApp and getting this error when I deploy
Not able to access static fields with OGNL with struts2 <s:checkbox name=operation fieldValue=@com.xx.xxx.webapp.action.EntryAction@OPERATIONAL />
I have this error when I try to include the tag ( http://code.google.com/p/struts2-jquery/wiki/HeadTag )
I have a Struts2 webapp, in which I compiled using the Tomcat 5.5 libraries.
I have been busy in my project creating a webapp (in struts) that manages
In struts2 version 2.1.x there is a new UnknownHandler that kicks in when a
I have recently inherited a J2EE Struts web app that was written back in
I got a Java Webapp project which uses Struts2 as the controller layer. I
I'm trying to integrate sitemesh into my struts2 app, but i'm finding that it's
I'm working on my first java struts2 webapp and want to be able to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.