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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:35:25+00:00 2026-05-24T20:35:25+00:00

I am running this code: int key = 25; String query = Select one,

  • 0

I am running this code:

int key = 25;
String query = "Select one, two, three, four, five from myTable where key=?";
List<Map<String,Object>> data = jdbcTemplate.queryForList(query, new Object[]{key});

//one is string, two is int, three is character, four is double, five is string
String one = null;
int two = 0;
char three = '\u0000';
double four = 0.0;
String five = null;

I want to set the five variables above with the values returned in the list. How?

  • 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-24T20:35:26+00:00Added an answer on May 24, 2026 at 8:35 pm

    I haven’t actually used JDBCTemplate, but according to the documentation, queryForList will return a List of Maps, with the keys in each Map being the names of the columns.

    So to assign those variables from the first returned row:

    Map<String,Object> row = data.get(0);
    String one  = (String)row.get("one");
    
    //these will not work -- Integer, Double incompatible with String
    /* int two     = ((Integer)row.get("two")).intValue();
    double four = ((Double)row.get("four")).doubleValue(); */
    
    //correct method
    int two     = Integer.parseInt((String)row.get("two"));
    double four = Double.parseDouble((String)row.get("four"));
    
    char three  = ((Character)row.get("three")).charValue();
        String five = (String)row.get("five");
    

    As you can see, for the object types, you should just be able to cast. For the primitives, I’ve cast to the object equivalent and then used that object equivalent’s method for getting the underlying primitive (so for int, cast to Integer and then use intValue).

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

Sidebar

Related Questions

I'm running code that sometimes yields this: UInt32 current; int left, right; ... //sometimes
I'm a beginner with jdbc ... I have a problem running this code :
I'm running this C# code in Visual Studio in debug mode: public class MyHandlerFactory
Running the static analyzer on this piece of code: - (id) readForeignPref { CFPropertyListRef
Running FxCop on my code, I get this warning: Microsoft.Maintainability : 'FooBar.ctor is coupled
Code is not running on .click when I have this: $(.cancel).click(function() { alert(got here);
Similar to this question , after running the following code the browser dialog does
Following the directions at this question , I have some code running to extract
Im running this query on the same server as the web application, so SPQuery.ExpandRecurrence
this time someone should please relpy i am struggling with running my code using

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.