Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Getting data from SQL query

 
Ranch Hand
Posts: 205
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 76472
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 235
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 76472
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
But how did the elephant get like that? What did you do? I think all we can do now is read this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic