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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:44:43+00:00 2026-05-25T02:44:43+00:00

I am having a java class where I am executing a query and assigning

  • 0

I am having a java class where I am executing a query and assigning the query result to an string array, finally return the array.

Everything works fine. But I want to return “no data” if the db values are empty (not the whole array). what can I do for this?

Code:

query="select `t1`,`t2`,`t3` from test";

                PreparedStatement pre = conn.prepareStatement(query);
                ResultSet res = pre.executeQuery();
                String val[][] = new String[res.getRow()][3];
           while (res.next()) {
                val[i][0] = res.getString(1);
                val[i][1] = res.getString(2);
                val[i][2] = res.getString(3);
                i++;
              }

                res.close();
                conn.close();
                pre.close();

                return (val);

(Where I want the val[1][1] to be “No Data” if res.getString(2) is null).

  • 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-05-25T02:44:43+00:00Added an answer on May 25, 2026 at 2:44 am

    No Data seems to be a value you display more than a logical value.

    So you should decide of a special value and display it in a special way. We usually call this a sentry value.

    This value could be null or a string that can’t be in your db. (maybe it doesn’t apply here as everything is often possible in a db).

    Also note that it could be attractive to use an exception instead of this special value but it is actually a very poor use of exceptions, mostly for performance issues and hence it is a design to avoid if possible except if this value can lead to problems for your clients classes.

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

Sidebar

Related Questions

Having read the documentation of Java's String class, it doesn't appear to support popping
I'm having an inexplicable problem with the Java Calendar class when I'm trying to
I need a mechanism to read session state from a Java class, without having
I'm having issues with a java class project. The first step consist in drawing
I am having difficulty executing a MS SQL Server stored procedure from Java/jsp. I
In the following java class i'm having a method authenticate, in which i'm using
When running a Java class through Ant, I was having a lot of trouble
I am having problems having my Java programs see classes that are packaged in
What reason is there for C# or java having lambdas? Neither language is based
My C++ is a little rusty having worked in Java and C# for the

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.