• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

How can you show data from a specific colum in a JList? through JDBC

 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI guys,

I have a table say, Staff and I want to show the surname colum in a JList.

Can any one tell me how can I do this.

after having my connection and PreStatment Object I tried the following Code. but could manage to do it.





The above code is okay and working, but when I try to show the LastName colume in a JList, it gives Error. the following code show how I am trying to Use JList with JDBC


The last two line goes inside a methode and could be called when an event is occured. I think the problems raise with the last two line as I am not sure about

Can any one please tell me, if there is a way to get it solved

thanks
Farhad

 
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The above code is okay and working, but when I try to show the LastName colume in a JList, it gives Error

What error? Compiler error? Runtime error?
 
Farhad Rahmati
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tom

it's compile error.

I have tried the following code though



allStaff is a JList object

Regards
 
Tom Reilly
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post the error. As I read the documentation the class JList does not have a method setListData() that accepts a List as a parameter.
 
Farhad Rahmati
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey Tom

I am using netbeans and Compile Error is shown with red underlined. I will tell you my story about this.

I have three classes

one for staff
one for all SQL queries
one for the GUI

I have a method (getAllPeople) in Queries Class and I have posted earliar. this method searchs for all and gets all the entries in the table which executes (Select * from Staff).
and it contains everything. forexample name, number, Id, salary, ................

I have created a JList instance in GUI class. now I call getAllPeople method with the following code which returns an ArrayList.

searchResult is an ArrayList or List.
Now I think all fields and columns are in the the list (e.g. Id, Name, surname, .............)
So, Now, how do you show only the Surname Column in JList?

 
rubbery bacon. crispy tiny ad:
professionally read, modify and write PDF files from Java
https://products.aspose.com/pdf/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!