File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and Relational Databases and the fly likes Problem with JDBC setResult on JTextarea Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Problem with JDBC setResult on JTextarea" Watch "Problem with JDBC setResult on JTextarea" New topic
Author

Problem with JDBC setResult on JTextarea

Behrouz Hosseini
Ranch Hand

Joined: Feb 15, 2010
Posts: 31
Hi guys,
I am trying to display a simple sql query result on a JTextArea.When I use a simple print line command I can get all data in console but when I replace the print command with append() I get these address instead of my data
com.mysql.jdbc.JDBC4ResultSet@1a16869
com.mysql.jdbc.JDBC4ResultSet@1a16869
com.mysql.jdbc.JDBC4ResultSet@1a16869
com.mysql.jdbc.JDBC4ResultSet@1a16869
com.mysql.jdbc.JDBC4ResultSet@1a16869

could you please let me know what's wrong?
Best Regards
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

'resultset' is an Object of type om.mysql.jdbc.JDBC4ResultSet. You'll have to pull the data out of the ResultSet to put in your textarea.


GenRocket - Experts at Building Test Data
Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
wrong forum


SCJP, SCJD, SCWCD, SCBCD
Behrouz Hosseini
Ranch Hand

Joined: Feb 15, 2010
Posts: 31
Gregg Bolinger ,
Thanks for you reply but what do you mean?
How can I do that? could you please explain me a bit more?
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

Might be a good idea for you to do a bit of reading up on ResultSet's and JDBC in general.

http://java.sun.com/docs/books/tutorial/jdbc/basics/retrieving.html
Behrouz Hosseini
Ranch Hand

Joined: Feb 15, 2010
Posts: 31
Darya Akbari wrote:wrong forum

Salam Darya,

I changed the txtResult.append(resultset.next() + "\n");
but what I get in Text area is some Boolean result like false and true!
Could you please let me know what is going on here?
I am sorry about wrong forum ,as well
Thanks again
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

Behrouz Hosseini,

It's clear you haven't read the link I provided. It will show you how to retrieve data from the ResultSet.
Behrouz Hosseini
Ranch Hand

Joined: Feb 15, 2010
Posts: 31
Ok I hope i can figure it out!
by the way , thanks again
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with JDBC setResult on JTextarea