• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Populating a Combo-Box from a Database Column?

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,

I'm using the JDBC driver to connect my Java program to a Microsoft Access database. I was wondering if there was any way that i could link up a combo-box so that its contents are obtained from a column in a database table. Is this possible? Any example code that would help give me an insight would be much appreciated!

Thanks in advance,

Emile
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to

1) Query the database to get the values from the column
2) Iterate over the ResultSet and put each value into a Vector
3) Construct the JComboBox with the Vector as the constructor argument.

Easy enough.
 
Emile Ghazzawi
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Seems logical, seeing as i always pull my Result Sets into a Vector anyway! Thanks for that, i'll give it a go, can't believe i didn't think of it!

Thanks again,

Emile
reply
    Bookmark Topic Watch Topic
  • New Topic