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

  • Home
  • SEARCH
  • 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 8909711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:30:06+00:00 2026-06-15T03:30:06+00:00

Hello I am working on a java code that is suppose to get the

  • 0

Hello I am working on a java code that is suppose to get the count of the total number of users in the user profile table I am working on. Now I am sure I got the sql statement right but for some reason I dont know how to get the numeric value from it. Any help is greatly appreciated and welcomed.I am sure the way I am trying to get the value doesn’t work but I dont know how to get the value, Here is the code below and thank you:

     public int getUserCount() throws SQLException {    

    Connection conn = null;
    Statement stmt = null;
    ResultSet rs = null;
    double encinfo;
    conn = DAOFactory.getDatabaseDAO().getConnection();
        StringBuffer query = new StringBuffer();
        query.append( "Select COUNT (DISTINCT record_id)");
        query.append( "From USER_PROFILE");
        stmt = conn.createStatement();
        rs = stmt.executeQuery( query.toString());
        if (!rs.next())
           throw new SQLException( SQLException.User_NOT_FOUND,"No User Count found.");

        // Should be able to get the user amount or value or total users in DB.
        userInfo = rs.getDouble( "USER_VALUE");

        m_userCount = (int) userInfo;
   }
  • 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-15T03:30:07+00:00Added an answer on June 15, 2026 at 3:30 am

    This may work:

    Add alias to record count:

      query.append( "Select COUNT (DISTINCT record_id) AS USER_VALUE");
            query.append( " From USER_PROFILE");
    

    Another way could be:

    rs.getDouble(1);
    

    Here 1 is the index of column.

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

Sidebar

Related Questions

I have some code that is working correctly in Java but when I try
Hello I'm working on a problem that requires me to change an set array
Hello all I am working in javascript and html5.I want to ask that how
Hello I have this list that i am working on. When i move the
hello its really weird that a if and else statement is not working in
So I have been working on a 2 player Tic-Tac-Toe game in java that
I need to write a code that compares performance of Java's ArrayList with Scala's
As the title states, I'm looking for a basic (working) tutorial of Java code
I've just started working with Java, and I've been trying to get the console
Like the title says, I can't get Canvas/CanvasLayer working in PlayN. My sample code

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.