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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:33:17+00:00 2026-06-01T00:33:17+00:00

I am working on a small Java EE web application. The problem I have

  • 0

I am working on a small Java EE web application. The problem I have is related to a sql statement.

I have entities messaging and users.

I have a method- getMessagesById(int msgid)

    public Messaging getMessagesByMid(int msgid) {

            String query = "SELECT msgid, msgsubject, msgcontent, timestamp, fname, lname FROM messaging INNER JOIN users ON messaging.users_userid=users.userid WHERE msgid=?;";

            try {
                PreparedStatement ps = conn.prepareStatement(query);
                ps.clearParameters();
                ps.setInt(1, msgid);

                ResultSet rs = ps.executeQuery();
                Messaging m= new Messaging();
                Users u= new Users();
                while (rs.next()) {
                    m.setMsgid((rs.getInt(1)));
                    m.setMsgsubject(rs.getString(2));
                    m.setMsgcontent(rs.getString(3));
                    m.setTimestamp(rs.getString(4));
                    m.setMsgrecipient(rs.getInt(5));
                    m.setUsers_userid(rs.getInt(6));
                    u.setFname(rs.getString(7));
                    u.setLname(rs.getString(8));
                }

                return m;
            } catch (Exception e) {
                System.out.println(e);
                return null;
            }
        }

The problem is how i return 2 data types?? messaging and bean..

  • 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-01T00:33:18+00:00Added an answer on June 1, 2026 at 12:33 am

    in Java, you cannot do this.

    Instead, try creating a new simple object containing both a Messaging and a Users

    For example

    public class MessageBox{
        private Messaging m;
        private Users u;
    
        //getters and setters for both values
        public Messaging getMessage(){
            return m;
        }
    }
    

    and then

    ResultSet rs = ps.executeQuery();
    Messaging m= new Messaging();
    Users u= new Users();
    MessageBox mb = new MessageBox();  //<-------
    
    ...
    m.setTimestamp(rs.getString(4));
    m.setMsgrecipient(rs.getInt(5));
    m.setUsers_userid(rs.getInt(6));
    u.setFname(rs.getString(7));
    u.setLname(rs.getString(8));
    mb.setMessage(m);  //<-----------
    mb.setUsers(u);  //<----------
    ...
    return mb;  //<------------
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on small web application for iPad Safari. I have to display
I'm working on a small Java project that now connects to a MS SQL
Im working on a small application to try out an idea that I have.
I have a small Spring (3.1.0.RELEASE) application, which was working just fine, until I
I'm currently maintaining a small-medium sized java web application (using only plain JSPs/Servlets) that
I have been working on a small web app using the Stripes framework. Now
I have been working for two weeks on JamVM, a small but powerful Java
I've build a small java application that uses selenium 2 to open a web
I am working to parse XML data in a java web application on Google
I'm working on a small java application that needs to load/save configuration properties. At

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.