Solved

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

Posted on 2009-05-06
3
11,029 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

697 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