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 the fly likes Method to retrieve information and output in GUI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Method to retrieve information and output in GUI" Watch "Method to retrieve information and output in GUI" New topic
Author

Method to retrieve information and output in GUI

Jean Maurice milazar
Greenhorn

Joined: May 17, 2010
Posts: 9
I have written a function which which take an argument to retrieve information from a database. My problem is that the result obtained should be output through a GUI. The function is trigerred at the GUI using using a button event. The code is as follows.



can anyone indicate me where i got things wrong and how i can make the method return the values one at a time and output them if i have textfields.(nametxt, addresstxt, agetxt..etc)
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
Where are you applying the information to your GUI? You are simply printing it to System.out. There is an example in the Java™ Tutorials about writing an Applet, and this section about tables may help too.
Jean Maurice milazar
Greenhorn

Joined: May 17, 2010
Posts: 9
Its actually the problem that i am having. I dont know how to apply the information to my GUI. The method is situated in different class than that of my GUI. It is only called there and expected to output its values through the text boxes.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
Which books do you have access to? Lots of books have such examples in; for example Deitel and Deitel has an example using MySQL and the names of their books, and there is an example in Horstmann and Cornell but I can't remember the details of their database.
Jean Maurice milazar
Greenhorn

Joined: May 17, 2010
Posts: 9
None of these books are available here. We have mastering javase1.4 and introductory java books. Is there a link where i can get access to electronic copy of these.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42931
    
  68
Many tech books are available through Safari: http://my.safaribooksonline.com/
Jean Maurice milazar
Greenhorn

Joined: May 17, 2010
Posts: 9
From the books i have read i've seen some additional lines that i should add to my code. I have added variables to take the values in the function.

But when i passed these variables to my textfield using the setText method i dont get the result. The modifiton is shown in the code and the way i call my method after that.




e.g method call is as follows.
OnclickBtnRetrieve{
viewStaffDetail (36);
txtLastname.setText(lastname);
txtFirstname.setText(firstname);
}

The values are still not shown in my textfields.

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
How are you setting up your text fields?

And please make sure not to show # # in quoted code; it makes it difficult to test.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Method to retrieve information and output in GUI