• Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting data from SQL query  RSS feed

 
John Morgan
Ranch Foreman
Posts: 78
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can access my database and return data however I need to have that data converted... right now it looks like
[package.method@396f6598] and I need it to return the actual value of what is in that data location.
(I hope that makes sense)

Basically I run a SQL script, it returns data from the table and then adds that data to a list, however when I look at the list I get the aforementioned results, not that actual table data

here is the code snippet I am using to create the list.
 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where are you displaying that result from? Did you override the toString method? That looks like the sort of thing you get if you don't override toString and use the Object class' version instead.
 
Robert D. Smith
Ranch Hand
Posts: 221
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what Campbell is asking with the override of the ToString method, so I guess I'd like to see the actual data you are getting. According to theOracle Docs Result Set
String getString(String columnLabel)
Retrieves the value of the designated column in the current row of this ResultSet object as a String in the Java programming language.
you should be getting proper data.

Regards,
Robert
 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I meant is that something is printing out as if the toString method had not been overridden:-
Yesterday, John Morgan wrote:right now it looks like [package.method@396f6598]
I think that actually means
package_name.ClassName@396f6598.
The class which encapsulates those data probably hasn't got its own toString method. It would appear that the data from the SQL query are going into that object and not being displayed in the required format.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!