Solved

How to extract values from entityManager.createNativeQuery(query).getResultList();

Posted on 2009-05-06
3
10,998 Views
Last Modified: 2012-05-06
Hello,

I execute a SQL statement, but the values of the resulset are diferents. I set the ArrayList as String and I try to extraact the resultset but I just get the Object for example Ljava.lang.Object;@1d31f85.

I read like this:
ArrayList<?> List = entity.Queries(DataSource, query);
                for (int i = 0; i <List.size(); i++) {

                    System.out.println("Resultset" +List.get(i));
              }

How can I extract the values?

Thank you!
public ArrayList<String> Queries(final String DataSource, final String query) {
        EntityManager entityManager = getEntityManagerDataSource(DataSource);
        return (ArrayList<String>) entityManager.createNativeQuery(query).getResultList();
 
    }
 
entityManager.createNativeQuery(query).getResultList();

Open in new window

0
Comment
Question by:Fionageo80
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 24314129
>>System.out.println("Resultset" +List.get(i));

Try
>>System.out.println("Resultset" + java.util.Arrays.toString((Object[])List.get(i)));

Open in new window

0
 

Author Comment

by:Fionageo80
ID: 24314409
Thanks a lot!
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24314433
:-)
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
groupSum6 challenge 6 86
servlet doXXX methods 3 48
factorial example 4 39
maven module vs maven project 3 22
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This video teaches viewers about errors in exception handling.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question