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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:16:01+00:00 2026-06-14T05:16:01+00:00

I have a ResultSet that i iterate over and i create a report like

  • 0

I have a ResultSet that i iterate over and i create a report like view (html).
The problem is that some columns return Long values (as a result of mathematical function in SQL).

Is there an easy way that I can identify this values by DataType?

Lets say i want to do something like this

String x = rs.getString(1);
if(MyUtilClass.isOfTypeLong(x)){
  //implement my bussiness logig
}

I have seen this post How do you determine the type of data contained in a string? . If there isn’t anything better right now, I will proceed with the regEx solution.

  • 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-14T05:16:02+00:00Added an answer on June 14, 2026 at 5:16 am

    Why don’t you try Long.valueOf(String) to first parse it as a Long, and failing that parse it as a Double with Double.valueOf(String)?

    Both throw a NumberFormatException if the string cannot be parsed.

    public static void main(String[] args) throws Exception {
        final String s1 = "1234567890";
        System.out.println(isParsableAsLong(s1));    // true
        System.out.println(isParsableAsDouble(s1));  // true
    
        final String s2 = "1234.56789";
        System.out.println(isParsableAsLong(s2));   // false
        System.out.println(isParsableAsDouble(s2)); // true
    }
    
    private static boolean isParsableAsLong(final String s) {
        try {
            Long.valueOf(s);
            return true;
        } catch (NumberFormatException numberFormatException) {
            return false;
        }
    }
    
    private static boolean isParsableAsDouble(final String s) {
        try {
            Double.valueOf(s);
            return true;
        } catch (NumberFormatException numberFormatException) {
            return false;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SelectSP which returns resultset that i am storing in the temp
I have a result of a db query in java.sql.ResultSet that needs to be
Given that I have this resultset structure (superfluous fields have been stripped) Id |
I have a java.sql.ResultSet object containg data from a query that was run. How
I have a query that creates a result set like this: Rank Name 1
I have a sample xml file that looks like this: <Books> <Category Genre=Fiction BookName=book_name
So, my problem is this. I have a legacy MySQL database that I'm building
The Problem I need some properties of each item that query returns as array
I'm getting returned a list with objects that have multiple attributes like so: results
I'm using NHibernate 3.2 and I have a repository method that looks like: public

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.