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 7778661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:27:14+00:00 2026-06-01T18:27:14+00:00

everyone. I have a rookie question about the returning value in java. Here’s my

  • 0

everyone. I have a rookie question about the returning value in java. Here’s my code.

@Override
public long addDrugTreatment(long id, String diagnosis, String drug,
        float dosage) throws PatientNotFoundExn {
    try {
        Patient patient = patientDAO.getPatientByDbId(id);
        long tid = patient.addDrugTreatment(diagnosis, drug, dosage);

        Connection treatmentConn = treatmentConnFactory.createConnection();
        Session session = treatmentConn.createSession(true, Session.AUTO_ACKNOWLEDGE);
        MessageProducer producer = session.createProducer(treatmentTopic);

        TreatmentDto treatment = null;
        ObjectMessage message = session.createObjectMessage();
        message.setObject(treatment);
        producer.send(message);

        return tid;
    } catch (PatientExn e) {
        throw new PatientNotFoundExn(e.toString());
    } catch (JMSException e) {
        logger.severe("JMS Error: " + e);
    }
}

Eclipse reports a “This method must return a result of type long” error. Yet I did return the tid in the try block; eclipse suggests to add a return value after the try/catch block, which would break the logic. Could you please tell me what wrong here? Thanks.

  • 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-01T18:27:15+00:00Added an answer on June 1, 2026 at 6:27 pm

    When a JMSException is thrown the return value is undefined. When an exception is thrown, control passes immediately to the exception handler. In this case, you log the error. Then control continues from that point which goes to the end of the function without returning a value. You either need to return a value or throw an exception.

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

Sidebar

Related Questions

everyone I have some question about tasks in Linux, I know that all tasks
Hello everyone i have an question about firefox add-on: How i can get the
Asking a simple question, just want everyone have fun to solve it. I got
hi there everyone i have a question on joomla, i have made a site
Hey everyone I have a basic search function here that allows me to search
Hello everyone I have a question that I will describe as good as I
Hi everyone i have one question i.e. i have some database table's which are
everyone -- I have a Heisenbug, here (only shows up with debugger detached!). Seems
hello everyone I have this snippet of the code: local helper(f, i, j) =
hello everyone I have this snippet of the code: local fun NTimesF(f, n:int) =

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.